googlesamples / unity-jar-resolver

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

[Bug] NullReferenceException: Object reference not set to an instance of an object Google.JarResolver.Dependency.IsGreater #712

Closed Plyrni closed 1 week ago

Plyrni commented 2 weeks ago

### [REQUIRED] Please fill in the following fields:

### [REQUIRED] Please describe the issue here: Steps to reproduce bug :

1 - Make new project ∟ Mine is Unity 2022.3.47f1 URP on Windows 2 - Add GooglePlayGames plugin : https://github.com/playgameservices/play-games-plugin-for-unity/tree/master/current-build 3 - A Warning appear : Non-secure network connections disabled in Player Settings (Followed by an error but we don't care) ∟ Allow it in ProjectSettings -> Player -> Other Settings -> Configuration -> Allow downloads over HTTP 4 - Add EDM4U registry ∟ Name : package.openupm.com ∟ URL : https://package.openupm.com ∟ Scope : com.google.external-dependency-manager 5 - Install EDM4U through Package Manager 6 - Switch project to Android 7 - Popup appear about auto resolution, just Disable (Annoying otherwise) 8 - Force resolve ∟ Conflicting dependency detected ∟ Get stuck at 100%, with no succeed or failed popup 9 - To fix it : Open "GooglePlayGamesPluginDependencies.xml" located in "Assets/GooglePlayGames/com.google.play.games/Editor/" ∟ Replace "Packages/com.google.play.games/Editor/m2repository" with "Assets/GooglePlayGames/com.google.play.games/Editor/m2repository" 10 - Force resolve doesn't work at this point, so close the editor and open it again 11 - Delete resolved libraries 12 - Force resolve ∟ Resolve succeed 13 - Build APK (I'm using LZ4HC) ∟ Build success 14 - Add Unity package "In App Purchasing" 15 - Delete resolved libraries 16 - Force resolve 17 - Try building ∟ Error : Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
18 - Enable Custom template : (located in Player Settings -> Publishing Settings -> Build ∟ Custom Main Gradle Template ∟ Custom Gradle Properties Template ∟ Custom Gradle Settings Template ∟ Note : I'm not sure we need Properties and Settings to trigger the bug, that's simply what I've done 19 - Delete resolved libraries 20 - Force resolve 21 - There you should have the error :

NullReferenceException: Object reference not set to an instance of an object
Google.JarResolver.Dependency.IsGreater (System.String version1, System.String version2) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/JarResolverLib/src/Google.JarResolver/Dependency.cs:196)
Google.JarResolver.Dependency+VersionComparer.Compare (System.String x, System.String y) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/JarResolverLib/src/Google.JarResolver/Dependency.cs:238)
GooglePlayServices.PlayServicesResolver.CheckGradleVersionForJetifier (System.Boolean useJetifier, System.String titlePrefix, System.Action`1[T] complete) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:2621)
GooglePlayServices.PlayServicesResolver.CanEnableJetifierOrPromptUser (System.String titlePrefix, System.Action`1[T] complete) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:2746)
GooglePlayServices.PlayServicesResolver.ResolveUnsafeAfterJetifierCheck (System.Action`1[T] resolutionComplete, System.Boolean forceResolution, System.Boolean isAutoResolveJob, System.Boolean closeWindowOnCompletion) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1752)
GooglePlayServices.PlayServicesResolver+<ScheduleResolve>c__AnonStorey21.<>m__44 () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1719)
GooglePlayServices.PlayServicesResolver.ExecuteNextResolveJob () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1576)
GooglePlayServices.PlayServicesResolver.ScheduleResolve (System.Boolean forceResolution, System.Boolean closeWindowOnCompletion, System.Action`1[T] resolutionCompleteWithResult, System.Boolean isAutoResolveJob) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1732)
GooglePlayServices.PlayServicesResolver.ExecuteMenuResolve (System.Boolean forceResolution) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:2032)
GooglePlayServices.PlayServicesResolver.MenuForceResolve () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:2056)

What's the issue repro rate? 100% repro rate Here is a downloadable project that reproduce the bug : https://we.tl/t-jrlWny5Uzo

google-oss-bot commented 2 weeks ago

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

txukiakari commented 2 weeks ago

I recently started a new project, and my setup is nearly identical to this. Running into the exact same issue.

Unity Version: 2022.3.45f1 EDM Version: 1.2.169 (included in latest Google Play Games plugin)

Plyrni commented 1 week ago

I'm still stuck on it

argzdev commented 1 week ago

Hey folks, thanks for reaching out. So far I'm unable to reproduce the same behavior. Here's what I did:

  1. Create project with Unity Editor 2022.3.47f1 and use Android platform
  2. Using Assets > Import Package > Custom Package.. add EDM4U 1.2.183
  3. Using Assets > Import Package > Custom Package.. add GooglePlayGamesPlugin-0.11.01.unitypackage
  4. This will trigger ED4MU auto resolution, resolve and remove duplicate EDM4U files version 1.2.169 from GooglePlayGamesPlugin
  5. Build And Run - Builds successfully
  6. Using Window > Package Manager > Add package by name add com.unity.purchasing version 4.12.2
  7. An error of not found packages of EDM4U version 1.2.169 is shown
  8. Use Resolve and Force Resolve
  9. Build And Run - Builds successfully

The stacktrace seems to point to an issue with the AGP version. Could you try updating your Minimum API level to 24 and your Target API level to 34 and higher?

txukiakari commented 1 week ago

Quick update on my end, I tried similar steps to what @argzdev listed. The exact details are below:

  1. Still on Unity 2022.3.45f1
  2. Imported EDM4U 1.2.183
  3. Imported GooglePlayGamesPlugin-0.11.01
    • It showed that it would replace(?) EDM4U 1.2.183 files, but in the end, it looks like it auto updated or something as it still shows I have version 1.2.183
  4. Changed my minimum API level to 24 and maximum API to latest (should resolve to 35)
  5. Attempted to build

At this point I ran into a different error, but I was able to resolve the error following this post: https://discussions.unity.com/t/build-failing-with-google-play-services-plugin-could-not-find-com-google-games0-11-01/319041/4

I've now successfully built my apk!

My play games authentication still fails, but that should be a completely different issue.

Plyrni commented 1 week ago

Issue still here on my side

  1. Move to Min API 24 and target Highest possible API

  2. Removed EDM4U 1.2.183

  3. Installed back EDM4U 1.2.183 (via registry, but it should be the same)

  4. Imported GPGP 0.11.01 again via unityPackage ∟ No error, no replacement of any sort during process. Unlike you guys

  5. Resolve and build succesfull

  6. Installed Unity Purchasing 4.12.2 ∟ No errors after install

  7. Resolve and Force resolve successful

  8. Build failed ∟ Execution failed for task ':launcher:checkDebugDuplicateClasses'.

  9. Enable Custom Main Gradle Template to fix the duplicates manualy

  10. Resolve and Force resolve fail ∟ The same error I mentionned above : NullReferenceException: Object reference not set to an instance of an object Google.JarResolver.Dependency.IsGreater (System.String version1, System.String version2)...

Plyrni commented 1 week ago

OK, I finally did it! Apparently the issue was UPM registry

  1. Move to Min API 24 and target Highest possible API
  2. I removed the UPM package
  3. Removed the ExternalDependencyManager folder
  4. Installed EDM4U 1.2.183 from unity package found here
  5. Assets -> Refresh ∟ External Dependency Manager appeared but didn't showed the resolver
  6. Assets -> External Dependency Manager -> Version Handler -> Update ∟ He found an obsolete file, I applied what he proposed.
  7. Android resolver appear in External Dependency Manager
  8. Force resolve suceed instantly (good sign that it works)
  9. Build succeed
argzdev commented 1 week ago

Interesting, so I guess the underlying issue is having redundant dependencies or sub-dependencies on both UPM and Custom Package which the EDM4U cannot resolve correctly. Thank you for sharing your updates, @txukiakari, @Plyrni. I'm sure this'll help guide other folks who encounter this issue as well. That said, since the issue has been resolved. I'll go ahead and close this thread.