googlesamples / unity-jar-resolver

Unity plugin which resolves Android & iOS dependencies and performs version management
Other
1.21k stars 337 forks source link

[Bug] Android ForceResolve can not copy files to GeneratedLocalRepo (bad folder name) #583

Open kkohno opened 1 year ago

kkohno commented 1 year ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)

  1. Open Unity project
  2. Switch to Android target
  3. enable Custom Mapi Gradle Template
  4. Set Up Google Play Games plugin for Unity v0.11.01 from .unipypackage without jar-resolver
  5. ForceResolve

Please answer the following, if applicable:

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

What happened? How can we make the problem occur?

Unable to copy Assets\GooglePlayGames\com.google.play.games\Editor\m2repository\com\google\games\gpgs-plugin-support\0.11.01\gpgs-plugin-support-0.11.01.srcaar to Assets\GeneratedLocalRepo\GooglePlayGames\com.google.play.games\Editor\m2repository\com\google\games\gpgs-plugin-support\0.11.01\gpgs-plugin-support-0.11.01.aar.  Assets\GeneratedLocalRepo\GooglePlayGames\com.google.play.games\Editor\m2repository\com\google\games\gpgs-plugin-support\0.11.01\gpgs-plugin-support-0.11.01.aar will not be included in Gradle builds. Reason: Failed to copy Assets\GooglePlayGames\com.google.play.games\Editor\m2repository\com\google\games\gpgs-plugin-support\0.11.01\gpgs-plugin-support-0.11.01.srcaar to Assets\GeneratedLocalRepo\GooglePlayGames\com.google.play.games\Editor\m2repository\com\google\games\gpgs-plugin-support\0.11.01\gpgs-plugin-support-0.11.01.aar due to System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\repos\KkohnoLibs\My project (2)\Assets\GeneratedLocalRepo\GooglePlayGames\com.google.play.games\Editor\m2repository\com\google\games\gpgs-plugin-support\0.11.01\gpgs-plugin-support-0.11.01.aar'.
  at System.IO.FileSystem.CopyFile (System.String sourceFullPath, System.String destFullPath, System.Boolean overwrite) [0x00060] in <8f06425e63004caf99a79845675f751e>:0 
  at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x00062] in <8f06425e63004caf99a79845675f751e>:0 
  at System.IO.File.Copy (System.String sourceFileName, System.String destFileName) [0x00000] in <8f06425e63004caf99a79845675f751e>:0 
  at GooglePlayServices.PlayServicesResolver.CopyAssetAndLabel (System.String sourceLocation, System.String targetLocation, System.Boolean force) [0x000a3] in /Users/drsanta/dev/tmp/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:2481 
UnityEngine.Debug:LogError (object)
Google.Logger:Log (string,Google.LogLevel) (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/Logger.cs:136)
GooglePlayServices.PlayServicesResolver:Log (string,Google.LogLevel) (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1069)
GooglePlayServices.GradleTemplateResolver:CopySrcAars (System.Collections.Generic.ICollection`1<Google.JarResolver.Dependency>) (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/AndroidResolver/src/GradleTemplateResolver.cs:167)
GooglePlayServices.GradleTemplateResolver:InjectDependencies (System.Collections.Generic.ICollection`1<Google.JarResolver.Dependency>) (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/AndroidResolver/src/GradleTemplateResolver.cs:488)
GooglePlayServices.PlayServicesResolver/<ResolveUnsafe>c__AnonStorey25:<>m__49 () (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1982)
Google.RunOnMainThread:ExecuteNext () (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:486)
Google.RunOnMainThread:<ExecuteAllUnnested>m__12 () (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:536)
Google.RunOnMainThread:RunAction (System.Action) (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:343)
Google.RunOnMainThread:ExecuteAllUnnested (bool) (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:530)
Google.RunOnMainThread:ExecuteAll () (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:512)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

image

It is can be fixed if created folder name("0" see screen) manually rename to 0.11.01.

Mminimal project to reproduce

google-oss-bot commented 1 year ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

paulinon commented 1 year ago

Hi @kkohno,

Thanks for reporting this issue. I've used the sample project you provided, and I wasn't able to encounter this issue on the first try. A different error message appeared, but it went away after enabling Custom Gradle Properties Template. However, I should mention that I used the editor's latest LTS version (2021.3.16). While I try using the sample project with the version you specified, could you try using the aforementioned version and see if this would be applicable to your use case?

kkohno commented 1 year ago

we encountered this bug a long time ago, long before version 2021.3.16. this version reproduses the same bug. Note, the bug can be reproduces on windows. It seems, that Path.GetDirectoryName works different on windows with directory names, that includes dots, and parsed as filename

I suspect this or this lines has unexpected behaviour with directory names such as 0.11.01 on windows

kkohno commented 1 year ago

Has reinstalled the project again from scratch. Reproduce steps 1 download project from repo 2 switch to android 3 call: Assets->External Dependency Manager->Android Resolver->Force Resolve (seems without bug, however error log) 4 repeate step 3

paulinon commented 1 year ago

Thanks for the update, @kkohno. I just realized that you're on a Windows machine while I was testing using macOS. Just tested using version 2022.2.1f1 on a Windows machine, and I was able to replicate this behavior. I'll be relaying my observations to the team about this. For now, let me mark this as a bug.

kkohno commented 1 year ago

ok, thanks

chkuang-g commented 1 year ago

Seems like @paulinon can reproduce this on Windows machine.

Hmm, I was expecting https://github.com/googlesamples/unity-jar-resolver/commit/ad55ee64e6bbd7e86b2bd650bf2c81b87917724e to fix this issue already. This should be part of 1.2.175.

I suspect that AssetDatabase.CreateFolder() or Directory.CreateDirectory() behave differently in this version of Unity on Windows. We can take a look.

kkohno commented 1 year ago

will be good

I suspect that AssetDatabase.CreateFolder() or Directory.CreateDirectory() behave differently in this version of Unity on Windows. We can take a look.

I face this bug with many versions of unity 2022 on Windows

Mino1214 commented 1 year ago

I solved the same problem, but I'm not sure it would help displaying Ads on device(I'm still testing). It seems when you press 'Force resolve' the resolver makes the folder name something like 0 or 0 1 or..so on. But the those folder name should be 0.11.01 as they say on the error, the path from the 'GooglePlayGames' and 'GeneratedLocalRepo' should be the same. After you modify the name of the folder then press the 'Force Resolve' then I would say succeed. However, If you just 'Resolve' again, the same problem will occur, so I'm not sure it would really work.

kkohno commented 1 year ago

I solved the same problem, but I'm not sure it would help displaying Ads on device(I'm still testing). It seems when you press 'Force resolve' the resolver makes the folder name something like 0 or 0 1 or..so on. But the those folder name should be 0.11.01 as they say on the error, the path from the 'GooglePlayGames' and 'GeneratedLocalRepo' should be the same. After you modify the name of the folder then press the 'Force Resolve' then I would say succeed. However, If you just 'Resolve' again, the same problem will occur, so I'm not sure it would really work.

Yes, it is solve problem, if rename directories manually. But another force resolve requires manually renamings again... It's annoying and not everyone will think of renaming folders.

ahmedameen2 commented 1 year ago

Hi, Any update on this?

cristianjuarezz commented 10 months ago

This plugin is so broken, I already tried everything

codrinalex1994 commented 7 months ago

Hi, any updates? @cristianjuarezz @ahmedameen2 @kkohno I have just to put this "0.11.01" instead of the folder named "0" everytime or there is another way? Please