firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
819 stars 424 forks source link

[Bug] Failing to copy libraries with Unity 2022 and maintemplate enabled #1272

Open epsmarkh opened 2 years ago

epsmarkh commented 2 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

When maintemplate.gradle is enabled and any firebase package is imported, the dependency manager fails to copy the files to the correct location in GeneratedLocalRepo. Builds and Force Resolve both fail with the error:

Unable to copy Assets\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\8.10.1\firebase-analytics-unity-8.10.1.srcaar to Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\8.10.1\firebase-analytics-unity-8.10.1.aar. Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\8.10.1\firebase-analytics-unity-8.10.1.aar will not be included in Gradle builds. Reason: Failed to copy Assets\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\8.10.1\firebase-analytics-unity-8.10.1.srcaar to Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\8.10.1\firebase-analytics-unity-8.10.1.aar due to System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\unity\Projects\testu22\Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\8.10.1\firebase-analytics-unity-8.10.1.aar'.

When browsing the directory, it has been incorrectly created as Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\8

instead of

Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\8.10.1

Steps to reproduce:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?

Yes, it also happens with an empty project with just maintemplate.gradle enabled and any firebase package imported

What's the issue repro rate? (eg 100%, 1/5 etc)

100%

What happened? How can we make the problem occur?

Create a project, switch to Android, enable maintemplate.gradle and import any firebase package. When attempting to build or use the EDM force resolve option, errors are shown and the build fails.

If you have a downloadable sample project that reproduces the bug you're reporting, you will likely receive a faster response on your issue.

Relevant Code:

N/A

paulinon commented 2 years ago

Hi @epsmarkh,

Thanks for letting us know about this. I've used the same versions of the Unity editor and the Firebase SDK, and I am facing this issue on my end.

I'll be marking this as a bug for now. You may refer to this thread for updates.

hjupter commented 2 years ago

I'm having the same problem on Mac with Apple Silicon

dreamcodestudio commented 2 years ago

the same problem Unity 2022.1.4f1 packages: external-dependency-manager 1.2.171 GooglePlayGamesPlugin v0.11.01 Firebase Unity 9.1.0

DeniMN commented 1 year ago

has anyone solved this problem?

dreamcodestudio commented 1 year ago

has anyone solved this problem?

for us it's work only with disabled mainTemplate in Unity Player Settings

DeniMN commented 1 year ago

has anyone solved this problem?

for us it's work only with disabled mainTemplate in Unity Player Settings

Thanks

CheeryLee commented 1 year ago

❗ Finally I found the reason why it's happening. There is a Unity bug, it's already registered, thus it's not related to Firebase at all: https://issuetracker.unity3d.com/issues/folder-name-is-truncated-when-dot-is-used-in-the-name

Be more concretically, you can find this code in FileUtils class that is part of AndroidResolver project: https://github.com/googlesamples/unity-jar-resolver/blob/master/source/VersionHandlerImpl/src/FileUtils.cs#L635

When recursion goes to dotted part of the path (8.10.1 in your case), CreateFolder method returns an error.

To solve the problem you can do one of the following things: 1) use explicit resolving as described before: libraries stay in Plugins folder; 2) downgrade to Unity version where the issue doesn't reproduce (can't imagine that someone will do this 😆 ); 3) replace the whole code of CreateFolder method with native Directory.CreateDirectory (requires manual resolver compiling).

jonesjacky commented 1 year ago

Simple yet Annoying Bug.

Found a simple solution :

No need to disable anything.

It simply cannot find/create the folder with the same version number in Generated Local Repo Directory if created through Unity Asset Browser.

1) Simply go to the directory through Windows Explorer and in my case it was "[THE LOCATION OF YOUR GAME PROJECT]\Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\". Or In Unity Asset Browser, browse to "Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\firebase-analytics-unity" and right-click, then "Show in Explorer".

2) Delete any existing folder and refresh in unity asset browser

3) Create a new folder with version number, mine was 9.3.0 and check inside unity if the folder has been synchronized. Only a folder with your corresponding version number should exist.

4) Do the same for all firebase folders, and then run Force resolve.

Voila!! Android Dependencies have been resolved.

dreamcodestudio commented 1 year ago

Simple yet Annoying Bug.

Found a simple solution :

No need to disable anything.

It simply cannot find/create the folder with the same version number in Generated Local Repo Directory if created through Unity Asset Browser.

  1. Simply go to the directory through Windows Explorer and in my case it was "[THE LOCATION OF YOUR GAME PROJECT]\Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity". Or In Unity Asset Browser, browse to "Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\firebase-analytics-unity" and right-click, then "Show in Explorer".
  2. Delete any existing folder and refresh in unity asset browser
  3. Create a new folder with version number, mine was 9.3.0 and check inside unity if the folder has been synchronized. Only a folder with your corresponding version number should exist.
  4. Do the same for all firebase folders, and then run Force resolve.

Voila!! Android Dependencies have been resolved.

it's simple, but it's not work if you frequencly updated plugins, we need worked, not 🔧"magical" solution It seems only like temp solution

jonesjacky commented 1 year ago

it's simple, but it's not work if you frequencly updated plugins, we need worked, not 🔧"magical" solution It seems only like temp solution

Of course, its a temporary solution. Its for the devs to fix it permanently as it is present in many versions of the editor, and I prefer not to touch the mess that the devs created, so hence my solution which hardly takes some time even if we add a couple different versions.

vangogih commented 1 year ago

Hey, @chkuang-g has already created PR-543 and after some time it will be merged to the unity-jar-resolver repo.

sercanaydemir commented 1 year ago

Simple yet Annoying Bug.

Found a simple solution :

No need to disable anything.

It simply cannot find/create the folder with the same version number in Generated Local Repo Directory if created through Unity Asset Browser.

  1. Simply go to the directory through Windows Explorer and in my case it was "[THE LOCATION OF YOUR GAME PROJECT]\Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity". Or In Unity Asset Browser, browse to "Assets\GeneratedLocalRepo\Firebase\m2repository\com\google\firebase\firebase-analytics-unity\firebase-analytics-unity" and right-click, then "Show in Explorer".
  2. Delete any existing folder and refresh in unity asset browser
  3. Create a new folder with version number, mine was 9.3.0 and check inside unity if the folder has been synchronized. Only a folder with your corresponding version number should exist.
  4. Do the same for all firebase folders, and then run Force resolve.

Voila!! Android Dependencies have been resolved.

that's worked, thank you!!

dreamcodestudio commented 1 year ago

Fix In Review https://issuetracker.unity3d.com/issues/folder-name-is-truncated-when-dot-is-used-in-the-name

Zarkend commented 1 year ago

for us it's work only with disabled mainTemplate in Unity Player Settings

Thanks it solved it for me too