quickstart-unity icon indicating copy to clipboard operation
quickstart-unity copied to clipboard

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

Open epsmarkh opened this issue 3 years ago • 14 comments

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2022.1.0f1
  • Firebase Unity SDK version: 8.10.1
  • Source you installed the SDK: tried both .unitypackage and Unity Package Manager
  • Problematic Firebase Component: All
  • Other Firebase Components in use: N/A
  • Additional SDKs you are using: None
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: Android
  • Scripting Runtime: IL2CPP

[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

epsmarkh avatar May 12 '22 10:05 epsmarkh

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.

paulinon avatar May 12 '22 13:05 paulinon

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

hjupter avatar Jun 09 '22 23:06 hjupter

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

yapetrichka avatar Jul 04 '22 08:07 yapetrichka

has anyone solved this problem?

DeniMN avatar Jul 23 '22 12:07 DeniMN

has anyone solved this problem?

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

yapetrichka avatar Jul 23 '22 12:07 yapetrichka

has anyone solved this problem?

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

Thanks

DeniMN avatar Jul 23 '22 13:07 DeniMN

❗ 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).

CheeryLee avatar Jul 27 '22 11:07 CheeryLee

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.

jonesjacky avatar Aug 03 '22 17:08 jonesjacky

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

yapetrichka avatar Aug 03 '22 18:08 yapetrichka

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.

jonesjacky avatar Aug 03 '22 21:08 jonesjacky

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

vangogih avatar Sep 30 '22 13:09 vangogih

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!!

sercanaydemir avatar Nov 24 '22 20:11 sercanaydemir

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

yapetrichka avatar Dec 04 '22 22:12 yapetrichka

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

Thanks it solved it for me too

Zarkend avatar Dec 07 '22 23:12 Zarkend