Skip to content

A null reference exception occurs when setting the target api level to API 29 in Unity. #344

@zippo227

Description

@zippo227

Settings

Unity editor version: Unity 2019.2.13 through Unity 2019.3.7 are the ones I tested
External Dependency Manager version: v0.10.07
Features in External Dependency Manager in use (Android Resolver, iOS Resolver, VersionHandler, etc.): UnityCompat Android Resolver
Plugins SDK in use (Firebase, Admob, Facebook, etc.): play-games-plugin-for-unity
Platform you are using the Unity editor on (Mac, Windows, or Linux): Mac
Platform you are targeting (iOS, Android, and/or desktop): Android
Scripting Runtime (Mono, and/or IL2CPP): .Net Standard 2.0, IL2CPP

Issue

When changing the target api level from automatic (which uses api 28) to API 29, the resolver throws an exception. I believe this has to do with some missing code in Unity, but it could be fixed with this plugin by using some better error handling and fewer assumptions in the VersionFromAndroidSDKVersionsEnum in UnityCompat.cs . I would like to attempt to fix it, but I'm not directly importing this plugin, I'm using the play-games-plugin-for-unity which had a similar bug filed but closed due to it being an issue elsewhere. playgameservices/play-games-plugin-for-unity#2790

Here is the error log:

NullReferenceException: Object reference not set to an instance of an object
GooglePlayServices.UnityCompat.VersionFromAndroidSDKVersionsEnum (System.String enumName, System.String fallbackPrefKey, System.Int32 fallbackValue) (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/UnityCompat.cs:58)
GooglePlayServices.UnityCompat.GetAndroidTargetSDKVersion () (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/UnityCompat.cs:116)
GooglePlayServices.PlayServicesResolver.CanEnableJetifierOrPromptUser (System.String titlePrefix) (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/PlayServicesResolver.cs:2314)
GooglePlayServices.PlayServicesResolver.ResolveUnsafe (System.Action1[T] resolutionComplete, System.Boolean forceResolution, System.Boolean isAutoResolveJob, System.Boolean closeWindowOnCompletion) (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/PlayServicesResolver.cs:1635) GooglePlayServices.PlayServicesResolver+<ScheduleResolve>c__AnonStorey1E.<>m__3F () (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/PlayServicesResolver.cs:1604) GooglePlayServices.PlayServicesResolver.ExecuteNextResolveJob () (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/PlayServicesResolver.cs:1461) GooglePlayServices.PlayServicesResolver.ScheduleResolve (System.Boolean forceResolution, System.Boolean closeWindowOnCompletion, System.Action1[T] resolutionCompleteWithResult, System.Boolean isAutoResolveJob) (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/PlayServicesResolver.cs:1617)
GooglePlayServices.PlayServicesResolver.ResolveSync (System.Boolean forceResolution, System.Boolean closeWindowOnCompletion) (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/PlayServicesResolver.cs:1514)
GooglePlayServices.PlayServicesResolver.OnPostProcessScene () (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/PlayServicesResolver.cs:1087)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <567df3e0919241ba98db88bec4c6696f>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <567df3e0919241ba98db88bec4c6696f>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <567df3e0919241ba98db88bec4c6696f>:0)
UnityEditor.Build.BuildPipelineInterfaces+AttributeCallbackWrapper.OnProcessScene (UnityEngine.SceneManagement.Scene scene, UnityEditor.Build.Reporting.BuildReport report) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:163)
UnityEditor.Build.BuildPipelineInterfaces+c__AnonStorey1.<>m__1 (UnityEditor.Build.IProcessSceneWithReport spp) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:387)
UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List1[T] oneInterfaces, System.Action1[T] invocationOne, System.Collections.Generic.List1[T] twoInterfaces, System.Action1[T] invocationTwo, System.Boolean exitOnFailure) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:356)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

Repro Rate

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

Temporary Workaround

From what I see in the codebase this function is not hit if jetifier is disabled, so I've disabled jetifier for now.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions