Build failure since upgrading to target API level 31

I’m still struggling with this issue, which is preventing me from releasing my new app to Google Play.

I’m also facing the situation that from November, if I can’t resolve this, I will be unable to release updates for the 14 other apps that I have currently published.

I’ve tried editng the link.xml as suggested here Unity Issue Tracker - [Android] Could not build an IL2CPP project when using 'GoogleMobileAds.dll' but that causes other build errors.

I’ve also tried editing the mainTemplate.gradle as described here Android 12 App crashes on startup due to error with PendingIntent (Google Mobile Ads plugin used) but this prevents Android dependency resolution from completing successfully.

The version of Unity I’m using now (2022.1.19f1) uses the version of Gradle recommended here Build failure with Android Target API 31

I am able to successfully build and run my app if I build using Mono, but the error persists with an IL2CPP build.

This is the build log from the latest attempt
Error Log

Building Library\Bee\artifacts\Android\ManagedStripped failed with output:
C:\Program Files\Unity\Hub\Editor\2022.1.19f1\Editor\Data\il2cpp\build\deploy\UnityLinker.exe --search-directory=C:/Unity/Git/Numerology/Numerology/Library/Bee/PlayerScriptAssemblies --search-directory=C:/Unity/Git/Numerology/Numerology/Assets/Plugins/Demigiant/DOTween --search-directory=C:/Program Files/Unity/Hub/Editor/2022.1.19f1/Editor/Data/PlaybackEngines/AndroidPlayer/Variations/il2cpp/Managed --search-directory=C:/Unity/Git/Numerology/Numerology/Library/PackageCache/com.unity.analytics@3.7.1/AnalyticsStandardEvents --search-directory=C:/Unity/Git/Numerology/Numerology/Assets/GoogleMobileAds --search-directory=C:/Unity/Git/Numerology/Numerology/Library/PackageCache/com.unity.analytics@3.7.1 --search-directory=C:/Unity/Git/Numerology/Numerology/Library/PackageCache/com.unity.nuget.newtonsoft-json@3.0.2/Runtime/AOT --search-directory=C:/Unity/Git/Numerology/Numerology/Assets/Plugins/Demigiant/DOTweenPro --search-directory=C:/Unity/Git/Numerology/Numerology/Assets/Plugins/Demigiant/DemiLib/Core --search-directory=C:/Program Files/Unity/Hub/Editor/2022.1.19f1/Editor/Data/MonoBleedingEdge/lib/mono/unityaot-linux --search-directory=C:/Program Files/Unity/Hub/Editor/2022.1.19f1/Editor/Data/MonoBleedingEdge/lib/mono/unityaot-linux/Facades --out=Library/Bee/artifacts/Android/ManagedStripped --include-link-xml=C:/Unity/Git/Numerology/Numerology/Temp/StagingArea/Data/Managed\MethodsToPreserve.xml --include-link-xml=C:/Unity/Git/Numerology/Numerology/Temp/StagingArea/Data/Managed\TypesInScenes.xml --include-link-xml=C:/Unity/Git/Numerology/Numerology/Temp/StagingArea/Data/Managed\SerializedTypes.xml --include-link-xml=C:\Unity\Git\Numerology\Numerology\Assets\link.xml --include-link-xml=C:\Unity\Git\Numerology\Numerology\Assets\GoogleMobileAds\link.xml --include-link-xml=C:/Program Files/Unity/Hub/Editor/2022.1.19f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools/AndroidNativeLink.xml --include-directory=C:/Unity/Git/Numerology/Numerology/Library/Bee/PlayerScriptAssemblies --include-directory=C:/Unity/Git/Numerology/Numerology/Assets/Plugins/Demigiant/DOTween --include-directory=C:/Program Files/Unity/Hub/Editor/2022.1.19f1/Editor/Data/PlaybackEngines/AndroidPlayer/Variations/il2cpp/Managed --include-directory=C:/Unity/Git/Numerology/Numerology/Library/PackageCache/com.unity.analytics@3.7.1/AnalyticsStandardEvents --include-directory=C:/Unity/Git/Numerology/Numerology/Assets/GoogleMobileAds --include-directory=C:/Unity/Git/Numerology/Numerology/Library/PackageCache/com.unity.analytics@3.7.1 --include-directory=C:/Unity/Git/Numerology/Numerology/Library/PackageCache/com.unity.nuget.newtonsoft-json@3.0.2/Runtime/AOT --include-directory=C:/Unity/Git/Numerology/Numerology/Assets/Plugins/Demigiant/DOTweenPro --include-directory=C:/Unity/Git/Numerology/Numerology/Assets/Plugins/Demigiant/DemiLib/Core --include-directory=C:/Program Files/Unity/Hub/Editor/2022.1.19f1/Editor/Data/MonoBleedingEdge/lib/mono/unityaot-linux --include-directory=C:/Program Files/Unity/Hub/Editor/2022.1.19f1/Editor/Data/MonoBleedingEdge/lib/mono/unityaot-linux/Facades --dotnetprofile=unityaot-linux --dotnetruntime=Il2Cpp --platform=Android --use-editor-options --engine-stripping-flag=EnableUnityConnect --engine-stripping-flag=EnablePerformanceReporting --engine-stripping-flag=EnableAnalytics --engine-modules-asset-file=C:/Program Files/Unity/Hub/Editor/2022.1.19f1/Editor/Data/PlaybackEngines/AndroidPlayer/modules.asset --editor-data-file=C:/Unity/Git/Numerology/Numerology/Temp/StagingArea/Data/Managed/EditorToUnityLinkerData.json --include-unity-root-assembly=C:/Unity/Git/Numerology/Numerology/Library/Bee/PlayerScriptAssemblies/Assembly-CSharp-firstpass.dll --include-unity-root-assembly=C:/Unity/Git/Numerology/Numerology/Library/Bee/PlayerScriptAssemblies/Assembly-CSharp.dll --include-unity-root-assembly=C:/Unity/Git/Numerology/Numerology/Library/Bee/PlayerScriptAssemblies/Unity.TextMeshPro.dll --include-unity-root-assembly=C:/Unity/Git/Numerology/Numerology/Library/Bee/PlayerScriptAssemblies/UnityEngine.UI.dll --include-unity-root-assembly=C:/Unity/Git/Numerology/Numerology/Library/Bee/PlayerScriptAssemblies/Unity.Analytics.DataPrivacy.dll --include-unity-root-assembly=C:/Unity/Git/Numerology/Numerology/Library/Bee/PlayerScriptAssemblies/UnityEngine.Purchasing.Codeless.dll --include-unity-root-assembly=C:/Unity/Git/Numerology/Numerology/Assets/Plugins/Demigiant/DOTween/DOTween.dll --print-command-line
Fatal error in Unity CIL Linker
Mono.Linker.LinkerFatalErrorException: ILLink: error IL1005: GoogleMobileAds.Api.MobileAds.GetClientFactory(): Error processing method ‘GoogleMobileAds.Api.MobileAds.GetClientFactory()’ in assembly ‘GoogleMobileAds.dll’
—> System.InvalidOperationException: No action for the assembly GoogleMobileAds.Unity, Version=7.2.0.0, Culture=neutral, PublicKeyToken=null defined
at Mono.Linker.AnnotationStore.GetAction(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(ICustomAttributeProvider provider, DependencyInfo& reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkTypeVisibleToReflection(TypeReference reference, DependencyInfo reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.<>c__DisplayClass20_4.b__7()
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.HandleCall(MethodBody callingMethodBody, MethodReference calledMethod, Instruction operation, ValueNodeList methodParams, ValueNode& methodReturnValue)
at Mono.Linker.Dataflow.MethodBodyScanner.HandleCall(MethodBody callingMethodBody, Instruction operation, Stack`1 currentStack)
at Mono.Linker.Dataflow.MethodBodyScanner.Scan(MethodBody methodBody)
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.ScanAndProcessReturnValue(MethodBody methodBody)
at Unity.Linker.Steps.UnityMarkStep.MarkReflectionLikeDependencies(MethodBody body, Boolean requiresReflectionMethodBodyScanner)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Unity.Linker.Steps.UnityMarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason)
at Unity.Linker.Steps.UnityMarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
— End of inner exception stack trace —
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Unity.Linker.Steps.UnityMarkStep.Process(LinkContext context)
at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Unity.Linker.UnityDriver.UnityRun(Boolean noProfilerAllowed, ILogger customLogger)
at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling(ILogger customLogger, Boolean noProfilerAllowed)
at Unity.Linker.UnityDriver.RunDriver()
UnityEngine.GUIUtility:processEvent (int,intptr,bool&)

This seems to be actual error

Fatal error in Unity CIL Linker
Mono.Linker.LinkerFatalErrorException: ILLink: error IL1005: GoogleMobileAds.Api.MobileAds.GetClientFactory(): Error processing method 'GoogleMobileAds.Api.MobileAds.GetClientFactory()' in assembly 'GoogleMobileAds.dll'

But I’ve no idea what to try now to resolve it, I would really appreciate it if anyone has any suggestions for what I should try next.

I’ve even tried submitting a bug report, but had no response from Unity apart from the automated reply following the bug report submission.

Tagging @Tomas1856 in the hope you may be able to suggest something.

Many thanks