Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Dependency Resolver Failure with Android API 31 Builds

Discussion in 'Editor & General Support' started by Kartari, Dec 22, 2022.

  1. Kartari

    Kartari

    Joined:
    Sep 2, 2015
    Posts:
    16
    Hi,

    In order to comply with Google Play's new target API level 31 requirement, I set my Target API Level (in Project Settings > Player) to "Android 12.0 (API level 31)" in Unity 2021.3. Unfortunately, a recurring error now occurs every time I run my app in the Editor. Worse, I cannot get Unity to build an APK file: it freezes on "Player" indefinitely every time I try to Build and Run.

    If I revert back to API 30, the error disappears and it can build and run again. Unfortunately, Google Play refuses to accept my APK on the grounds it does not meet its new API level 31 requirement.

    The error and full stack trace I get in Unity Console is:

    Stopped polling job due to exception: System.NullReferenceException: Object reference not set to an instance of an object
    at GooglePlayServices.UnityCompat.VersionFromAndroidSDKVersionsEnum (System.String enumName, System.String fallbackPrefKey, System.Int32 fallbackValue) [0x00001] in <48abf529805a49c69e88ffb3f8b573e9>:0
    at GooglePlayServices.UnityCompat.GetAndroidTargetSDKVersion () [0x00036] in <48abf529805a49c69e88ffb3f8b573e9>:0
    at GooglePlayServices.PlayServicesResolver.CanEnableJetifierOrPromptUser (System.String titlePrefix) [0x000b0] in <48abf529805a49c69e88ffb3f8b573e9>:0
    at GooglePlayServices.PlayServicesResolver.ResolveUnsafe (System.Action1[T] resolutionComplete, System.Boolean forceResolution, System.Boolean isAutoResolveJob, System.Boolean closeWindowOnCompletion) [0x00014] in <48abf529805a49c69e88ffb3f8b573e9>:0 at GooglePlayServices.PlayServicesResolver+<>c__DisplayClass102_0.<ScheduleResolve>b__1 () [0x0001f] in <48abf529805a49c69e88ffb3f8b573e9>:0 at GooglePlayServices.PlayServicesResolver.ExecuteNextResolveJob () [0x00073] in <48abf529805a49c69e88ffb3f8b573e9>:0 at GooglePlayServices.PlayServicesResolver.ScheduleResolve (System.Boolean forceResolution, System.Boolean closeWindowOnCompletion, System.Action1[T] resolutionCompleteWithResult, System.Boolean isAutoResolveJob) [0x000ac] in <48abf529805a49c69e88ffb3f8b573e9>:0
    at GooglePlayServices.PlayServicesResolver.AutoResolve (System.Action resolutionComplete) [0x00018] in <48abf529805a49c69e88ffb3f8b573e9>:0
    at GooglePlayServices.PlayServicesResolver+<>c.<ScheduleAutoResolve>b__78_1 () [0x00024] in <48abf529805a49c69e88ffb3f8b573e9>:0
    at Google.RunOnMainThread.ExecutePollingJobs () [0x00052] in <ac8e755fbc27434ebdaf117e2c7041d9>:0
    UnityEngine.Debug:LogError (object)
    Google.RunOnMainThread:ExecutePollingJobs ()
    Google.RunOnMainThread/<>c:<ExecuteAll>b__24_0 ()
    Google.RunOnMainThread:RunAction (System.Action)
    Google.RunOnMainThread:ExecuteAll ()
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()


    I surmise it's getting a null exception due to some kind of package resolution error with, I would believe, either the Android SDK or the Play Services Resolver. I've tried several attempts to resolve this problem, to no avail:
    • Upgraded to Unity 2022.2: no change.
    • Changed the Android SDK path to point to Android Studio's folder: no change.
    • Changed that path back, and replaced Unity's Android API 31 folder's contents with the contents of Android Studio's equivalent folder contents: no change.
    • Disabled "Use Jetifier" in Android Resolver Settings (in Assets > Mobile Dependency Resolver): it produces a warning plus the same same error, and fails on a Jetbrains dependency every time.
    • Tried installing the External Dependency Manager for Unity package from GitHub: Unity refused to allow it to install, bad package error of some kind.
    • Tried installing it from disk: Unity did not respond, as if I did not do anything.
    • Removed the Jetbrains package, since the Dependency Resolver was freezing on one of the Jetbrains packages when the error came up: no change.
    • Removed the Unity Advertising and Mediation package since a warning also comes up "[Mediation]: Warning, failed to retrieve game id from Dashboard...": no change.
    • Uninstalled Unity 2021.3 and Unity 2022.2, uninstalled Android Studio, and reinstalled all three: no change.
    • Searching online for a solution proved fruitless: I found a few seemingly related posts, but they either applied to an old Unity version or I tried their solutions and they didn't work.
    I've spent several hours trying to resolve this problem and am at my wits end. If anyone has a clue, please help! My team is trying to open up to 50 alpha testers now, and we're on hold...

    Thank you!

    Peace,
    Brian
     
    Last edited: Dec 22, 2022
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,312
    How to troubleshoot build failures:

    First, make a blank project with a single blank scene and prove that it builds successfully.

    If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.

    Until you can build a blank project to the target platform, don't fiddle with anything else.

    Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

    Most often things that prevent building are third-party libraries such as Firebase.

    Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

    It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.

    Android build not building:

    Recently (circa July 2022) there have been reports of Unity's installer failing to install the Android Tools.

    https://forum.unity.com/threads/cant-build-for-android.1306098/

    Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022:

    https://forum.unity.com/threads/aab...y-2021-3-8-with-jdk-1-8.1322211/#post-8551193

    Android Gradle errors and other related stuff:

    https://forum.unity.com/threads/unity-gradle-bug-please-help.1368018/#post-8625789
     
    Rocaguinarda and Kartari like this.
  3. Kartari

    Kartari

    Joined:
    Sep 2, 2015
    Posts:
    16
    Hi Kurt. Thanks so much, that looks like a sound general strategy for figuring out difficult problems. I'll go through those steps and will report back.
     
  4. Kartari

    Kartari

    Joined:
    Sep 2, 2015
    Posts:
    16
    I was able to successfully build an empty 3D Unity project targeting API level 31.

    Maybe it's just time to import all my code and resources into a new, empty project. A clean restart... this app was first created for either Unity 4 or 5 back in 2017 or 2018, I think. Maybe converting it to Unity 2018, then 2019, 2020, 2021, and now 2022 has left some problematic remnants in there...
     
    Kurt-Dekker likes this.
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,312
    That's actually a thing. Most of my games date back to 2012 to 2014 so I have done this modernization step a few times: just dropped Assets into a new Project and moved it back into place so source control could identify what I should change, like names and bundles and versions and whatnot.
     
    Kartari likes this.
  6. Mortu

    Mortu

    Joined:
    Dec 14, 2021
    Posts:
    6
    I'm had the same exact error, with an identical full stack trace in the Unity Console. Unity version 2021.3.15f1.

    I fixed it by going to Assets -> Mobile Dependency Resolver -> Android Resolver -> Settings and selecting "Use Gradle Daemon".

    Screenshot 2022-12-22 at 3.03.02 PM.png
     
    valonsoft and Kartari like this.
  7. Kartari

    Kartari

    Joined:
    Sep 2, 2015
    Posts:
    16
    I'm glad to know this is a thing, because at least there's a way forward LOL. Thanks again.
     
  8. Kartari

    Kartari

    Joined:
    Sep 2, 2015
    Posts:
    16
    I appreciate that Mortu. Unfortunately, it didn't make a difference in Unity 2022.2 in my case. I tried turning off Jetifier again as well, so that just Gradle Daemon would attempt to resolve dependencies.

    I'll try reverting back to 2021.3 and see what happens. EDIT: Yep, that didn't work. Thanks for the idea though!
     
    Last edited: Dec 23, 2022
  9. firesightstudios

    firesightstudios

    Joined:
    Mar 29, 2022
    Posts:
    56
    I'm also having issues building android as I just got IOS working.
    I keep getting
    Code (CSharp):
    1. Temp\PlayServicesResolverGradle', Native error= The system cannot find the file specified.
    2.  
    The android resolver throws that error when manually resolving and when I try to build just gets stuck trying to build my first scene for a long time. I eventually have to force close unity.
     
  10. firesightstudios

    firesightstudios

    Joined:
    Mar 29, 2022
    Posts:
    56
    I got mine fixed. It was apparently where I had originally had the custom keystore set and when I ported to a new project I forgot to load the keystore again. Now all is well.
     
  11. etiennecadicfrog

    etiennecadicfrog

    Joined:
    Aug 7, 2023
    Posts:
    1
    Same issue for upgrading from Android 32 to 33.

    Had to delete MobileDependencyResolver folder so that it got reimported automatically with the latest API codes available
     
  12. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    I can't seems to get a blank project with ironsource and the unity ads adaptor to resolve. And i get the same issue with ironsource and facebook sdk in a blank project. The resolver just resolvers the same files over and over and over without ending.

    Ironsource on its own in a blank project works, and facebok on its own works. Any combination of ironsource and adaptors or facebook and ironsource, broken.

    Any ideas?