Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Android resolver fails to copy srcaar files to Maven repository for Packages in custom external paths #701

Closed
jonsenson-uken opened this issue Aug 2, 2024 · 8 comments · Fixed by #710
Assignees

Comments

@jonsenson-uken
Copy link

jonsenson-uken commented Aug 2, 2024

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2022.3.22
  • External Dependency Manager version: 1.2.180
  • Source you installed EDM4U: .unitypackage
  • Features in External Dependency Manager in use: Android Resolver
  • Plugins SDK in use: Firebase, Facebook
  • Platform you are using the Unity editor on: Mac

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

Packages that are are not in either the Packages or Assets folder generate an exception when attempting to copy .srcaar files into the local Maven repo. These are Packages referenced using local file paths as described in the Unity docs here. In our case our Firebase package lives in a folder parallel to Assets so the manifest entry looks like:

"dependencies": {
  "com.company.firebase.app": "file:../CompanyPackages/node_modules/com.company.firebase.app",
  etc...
}

The exception happens in FileUtils.CreateFolder. Since an external folder path is sent into this method and it only checks to see if the folder exists in AssetDatabase, it gets stuck in a recursive loop until path is an empty string and new DirectoryInfo(path) throws the following exception:

Job failed with exception: System.ArgumentException: The specified path is not of a legal form (empty).
  at System.IO.Path.InsecureGetFullPath (System.String path) [0x00025] in <b904252b6b4e4277834bcca7e51f318d>:0 
  at System.IO.Path.GetFullPath (System.String path) [0x00000] in <b904252b6b4e4277834bcca7e51f318d>:0 
  at System.IO.DirectoryInfo..ctor (System.String path) [0x00006] in <b904252b6b4e4277834bcca7e51f318d>:0 
  at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo..ctor(string)
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x00010] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x0001e] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x0001e] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x0001e] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x0001e] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x0001e] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x0001e] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x0001e] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x0001e] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x0001e] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at Google.FileUtils.CreateFolder (System.String path, Google.Logger logger) [0x0001e] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
  at GooglePlayServices.PlayServicesResolver.CopyAssetAndLabel (System.String sourceLocation, System.String targetLocation, System.Boolean force) [0x0009b] in <bd68bc0fc2b34107a6e5a63d15643d80>:0 
  at GooglePlayServices.GradleTemplateResolver.CopySrcAars (System.Collections.Generic.ICollection`1[T] dependencies) [0x000be] in <bd68bc0fc2b34107a6e5a63d15643d80>:0 
  at GooglePlayServices.GradleTemplateResolver.InjectDependencies (System.Collections.Generic.ICollection`1[T] dependencies) [0x00140] in <bd68bc0fc2b34107a6e5a63d15643d80>:0 
  at GooglePlayServices.PlayServicesResolver+<>c__DisplayClass115_0.<ResolveUnsafe>b__3 () [0x0000c] in <bd68bc0fc2b34107a6e5a63d15643d80>:0 
  at Google.RunOnMainThread.ExecuteNext () [0x00047] in <35cc61ad4ecc44e4bdeaad3e377694d3>:0 
UnityEngine.Debug:LogError (object)
Google.RunOnMainThread:ExecuteNext ()
Google.RunOnMainThread/<>c:<ExecuteAllUnnested>b__28_0 ()
Google.RunOnMainThread:RunAction (System.Action)
Google.RunOnMainThread:ExecuteAllUnnested (bool)
Google.RunOnMainThread:Run (System.Action,bool)
GooglePlayServices.PlayServicesResolver:ResolveUnsafe (System.Action`1<bool>,bool,bool)
GooglePlayServices.PlayServicesResolver:ResolveUnsafeAfterPromptCheck (System.Action`1<bool>,bool,bool,bool)
GooglePlayServices.PlayServicesResolver/<>c__DisplayClass113_0:<ResolveUnsafeAfterJetifierCheck>b__0 (bool)
GooglePlayServices.PlayServicesResolver/<>c__DisplayClass144_0:<CanEnableJetifierOrPromptUser>b__1 (GooglePlayServices.PlayServicesResolver/ApiLevelJetifierResult)
GooglePlayServices.PlayServicesResolver:CheckApiLevelForJetifier (bool,string,System.Action`1<GooglePlayServices.PlayServicesResolver/ApiLevelJetifierResult>)
GooglePlayServices.PlayServicesResolver/<>c__DisplayClass144_0:<CanEnableJetifierOrPromptUser>b__0 (bool)
GooglePlayServices.PlayServicesResolver:CheckGradleVersionForJetifier (bool,string,System.Action`1<bool>)
GooglePlayServices.PlayServicesResolver:CanEnableJetifierOrPromptUser (string,System.Action`1<bool>)
GooglePlayServices.PlayServicesResolver:ResolveUnsafeAfterJetifierCheck (System.Action`1<bool>,bool,bool,bool)
GooglePlayServices.PlayServicesResolver:ResolveUnsafeAfterMainTemplateCheck (System.Action`1<bool>,bool,bool,bool)
GooglePlayServices.PlayServicesResolver/<>c__DisplayClass110_0:<ScheduleResolve>b__1 ()
GooglePlayServices.PlayServicesResolver:ExecuteNextResolveJob ()
GooglePlayServices.PlayServicesResolver:ScheduleResolve (bool,bool,System.Action`1<bool>,bool)
GooglePlayServices.PlayServicesResolver:ExecuteMenuResolve (bool)
GooglePlayServices.PlayServicesResolver:MenuForceResolve ()

Please answer the following, if applicable:

What's the issue repro rate? 100%

What happened? How can we make the problem occur?

  • Link any Package that contains a .srcaar file, like Firebase, in manifest.json via a relative or absolute path to any folder outside of either Packages or Assets
  • Set the resolver settings to patch the main gradle Template file and enable the local Maven repo
  • Run the resolver
  • After the exception is triggered the resolver becomes completely unresponsive and selecting Resolve again does nothing at all until Unity is fully relaunched.
@google-oss-bot
Copy link

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

@argzdev argzdev removed the new to be triaged label Aug 2, 2024
@ferretnt
Copy link

ferretnt commented Sep 5, 2024

I've just run into this and am shocked that the only activity on this issue is a bot saying "meh, try harder."

As far as I can see, the steps to install firebase using UPM packages here:

https://firebase.google.com/docs/unity/setup-alternative

No longer work because they place the tgz files in a parallel GooglePackages folder. I’m surprised I’m the first to waste an afternoon on this. I naively assumed that most developers don’t want several folders of firwbase through their assets folder.

This post written in a grumpy mood after this finalized an afternoon of utter nonsense. Including having to upgrade ruby so I can upgrade gem so I can upgrade cocoapods to get iOS to build. The entire firebase unity package is a hellhole of 5 separate insane build systems that I would gladly take out the back and shoot (already using rest for auth, db, etc) if it weren’t for the fact that there is no REST api for analytics and we need conversion events for google ads to target.

@ferretnt
Copy link

ferretnt commented Sep 6, 2024

If this was the wrong place or procedure for this bug report originally I’d love to know the correct one. Kudos to the original author for taking the time to debug.

@argzdev argzdev self-assigned this Sep 6, 2024
@argzdev
Copy link
Collaborator

argzdev commented Sep 6, 2024

Hi folks, I took a look into this, and so far I'm unable to reproduce the same behavior. Here's the steps I took:

  1. Use Firebase Quickstart Unity for Analytics
  2. Open the app using Unity Editor 2022.3.40f1
  3. Add the dependencies using UPM
    • I added the .tgz files in parallel with the Packages or Assets folder. (.e.g "com.google.external-dependency-manager": "file:../GooglePackages/com.google.external-dependency-manager-1.2.182.tgz")
    • I checked the patch mainTemplate.gradle is turned on by default
    • I enabled Use Full Custom Local Maven Repo Path > When building Android app through Unity

Not sure if I'm missing anything(?) But so far, I tried using both methods via Package Manager UI and manifest.json, both seems to be working correctly (Resolve works, and no errors are shown). One thing I noticed is that you don't have the .tgz file extension at the end of dependency declaration. Could this be causing the issue? ("com.company.firebase.app": "file:../CompanyPackages/node_modules/com.company.firebase.app"). Also this is by a long shot and I'm sure it wouldn't make a difference, but could you try updating to the latest Unity version 2022.3.40f1 and see if that changes anything?

@argzdev argzdev added needs-info Need information for the developer type: question and removed type: question labels Sep 6, 2024
@ferretnt
Copy link

ferretnt commented Sep 6, 2024

Sounds like you were able to reproduce this in the other issue #697, and that it was Unity 6 specific, which honestly I should have confirmed, but I saw the 2022.3 at the top of the issue and so didn't. If so we can probably link and close this issue.

@jonsenson-uken
Copy link
Author

One thing I noticed is that you don't have the .tgz file extension at the end of dependency declaration. Could this be causing the issue? ("com.company.firebase.app": "file:../CompanyPackages/node_modules/com.company.firebase.app")

com.company.firebase.app is actually a (unfortunately named since it clashes with mac os naming) folder containing the uncompressed contents of the library. I'm not the one who implemented that so am unsure why or how this structure was set up. It makes sense that linking just a whole .tgz file would work since the dependency manager wouldn't find the loose .srcaar files inside and attempt to copy them so you've effectively circumvented the bug. The external library needs to be a raw folder that contains loose .srcaar files to trigger the issue.

Unfortunately we've made significant edits and progress on the project since reporting this that would make it difficult to revert and put things back into the bugged state and I don't have the free time to investigate further. Updating to Unity 2022.3.40 to test also wouldn't be doable at this point since it contains breaking changes to our build system.

Sounds like you were able to reproduce this in the other issue #697, and that it was Unity 6 specific, which honestly I should have confirmed, but I saw the 2022.3 at the top of the issue and so didn't. If so we can probably link and close this issue

From what I see in that issue it appears to generate the same error but the root cause in that issue is a different Unity 6 specific problem that's unrelated to this one.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Sep 6, 2024
@argzdev
Copy link
Collaborator

argzdev commented Sep 11, 2024

Thank you for the well detailed explanation, @jonsenson-uken. I'm now able to reproduce the same behavior when linking the uncompressed library. Testing with both versions of Unity Editor 2022.3.40f1 and 2022.3.22f1, and EDM versions 1.2.182 and 1.2.180 yields the same result.

@ferretnt, I agree with @jonsenson-uken, this could be a different issue. But thank you for the feedback! In any case, I'll raise this to our engineering team to take a closer look and see what we can do here.

@argzdev argzdev added type: bug and removed type: question needs-attention Need Googler's attention labels Sep 11, 2024
a-maurice added a commit that referenced this issue Sep 17, 2024
# Version 1.2.183 - Sep 17, 2024
* Android Resolver - Handle package paths that don't include a version hash,
  which is no longer present with Unity 6. Fixes #697
* Android Resolver - Handle packages referenced using local file paths.
  Fixes #701
@argzdev
Copy link
Collaborator

argzdev commented Sep 18, 2024

Hey folks, I believe the referenced PR fixes this issue, and will be released in version 1.2.183. That said, I'll go ahead and close this thread. Thanks!

@argzdev argzdev closed this as completed Sep 18, 2024
a-maurice added a commit that referenced this issue Sep 18, 2024
* Version 1.2.183

# Version 1.2.183 - Sep 17, 2024
* Android Resolver - Handle package paths that don't include a version hash,
  which is no longer present with Unity 6. Fixes #697
* Android Resolver - Handle packages referenced using local file paths.
  Fixes #701

* Update release date
@googlesamples googlesamples locked and limited conversation to collaborators Oct 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants