Build Errors after updating Unity to 6.5

Hello,

Just updated my project from 6.2 to 6.5 (in order to update the IAP settings to the newest billing version), and now I’m unable to build my project. In my efforts to fix things, I updated the Google Mobile Ads plugin as well, but am still having no luck.

These are the error messages I’m getting:

> Configure project :launcher
WARNING: The option setting 'android.builtInKotlin=false' is deprecated.
The current default is 'true'.
It will be removed in version 10.0 of the Android Gradle plugin.
WARNING: The option setting 'android.enableJetifier=true' is deprecated.
The current default is 'false'.
It will be removed in version 10.0 of the Android Gradle plugin.

> Configure project :unityLibrary
Variant 'debug', will keep symbols in binaries for:
  'libunity.so'
  'libil2cpp.so'
  'libmain.so'
Variant 'release', symbols will be stripped from binaries.

> Configure project :launcher
Variant 'debug', will keep symbols in binaries for:
  'libunity.so'
  'libil2cpp.so'
  'libmain.so'
Variant 'release', symbols will be stripped from binaries.

> Configure project :unityLibrary:GooglePlayGamesManifest.androidlib
WARNING: minSdkVersion (26) is greater than targetSdkVersion (16) for variant "debug". Please change the values such that minSdkVersion is less than or equal to targetSdkVersion.
WARNING: minSdkVersion (26) is greater than targetSdkVersion (16) for variant "release". Please change the values such that minSdkVersion is less than or equal to targetSdkVersion.
WARNING: We recommend using a newer Android Gradle plugin to use compile SDK version 37.0

This Android Gradle plugin (9.0.0) was tested up to compile SDK version 36.1.

You are strongly encouraged to update your project to use a newer
Android Gradle plugin that has been tested with compile SDK version 37.0.

If you are already using the latest version of the Android Gradle plugin,
you may need to wait until a newer version with support for compile SDK version 37.0 is available.

For more information refer to the compatibility table:
https://d.android.com/r/tools/api-level-support

To suppress this warning, add/update
    android.suppressUnsupportedCompileSdk=37.0
to this project's gradle.properties.
Observed package id 'platforms;android-37.0' in inconsistent location 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0-2' (Expected 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0')
Observed package id 'platforms;android-37.0' in inconsistent location 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0-2' (Expected 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0')
Observed package id 'platforms;android-37.0' in inconsistent location 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0-2' (Expected 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0')

[Incubating] Problems report is available at: file:///D:/My_Documents/UnityProjects/TidalWaveTom/Library/Bee/Android/Prj/IL2CPP/Gradle/build/reports/problems/problems-report.html

Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/9.1.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':launcher:bundleReleaseResources'.
> Failed to find target with hash string 'android-37' in: C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to generate a Build Scan (Powered by Develocity).
> Get more help at https://help.gradle.org.

BUILD FAILED in 17s

UnityEditor.EditorApplication:Internal_CallDelayFunctions ()
CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-9.1.0.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "bundleRelease" 

Environment Variables:
__PSLockDownPolicy = 0
NVIDIAWHITELISTED = 0x01
USERDOMAIN = LAPTOP-CNLTUAGR
ProgramFiles = C:\Program Files
TMP = C:\Users\SILVER~1\AppData\Local\Temp
PROCESSOR_ARCHITECTURE = AMD64
PROCESSOR_REVISION = 9e0a
OneDriveConsumer = C:\Users\Silver Fang\OneDrive
OS = Windows_NT
ALLUSERSPROFILE = C:\ProgramData
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
ProgramW6432 = C:\Program Files
ADSK_CLM_WPAD_PROXY_CHECK = FALSE
USERPROFILE = C:\Users\Silver Fang
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\WINDOWS\system32\cmd.exe
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
ANDROID_NDK_ROOT = C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
USERNAME = Silver Fang
NUMBER_OF_PROCESSORS = 8
HOMEDRIVE = C:
TEMP = C:\Users\SILVER~1\AppData\Local\Temp
Path = C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NGX;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Calibre2\;C:\Users\Silver Fang\AppData\Local\Microsoft\WindowsApps;;C:\Users\Silver Fang\AppData\Roaming\Amazon;C:\Users\Silver Fang\.dotnet\tools
COMPUTERNAME = LAPTOP-CNLTUAGR
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
SystemDrive = C:
windir = C:\WINDOWS
HOMEPATH = \Users\Silver Fang
PUBLIC = C:\Users\Public
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\Silver Fang\AppData\Roaming
OneDrive = C:\Users\Silver Fang\OneDrive
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
SystemRoot = C:\WINDOWS
SESSIONNAME = Console
LOGONSERVER = \\LAPTOP-CNLTUAGR
LOCALAPPDATA = C:\Users\Silver Fang\AppData\Local
SHIM_MCCOMPAT = 0x810000001
USERDOMAIN_ROAMINGPROFILE = LAPTOP-CNLTUAGR
ProgramData = C:\ProgramData


stderr[

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':launcher:bundleReleaseResources'.
> Failed to find target with hash string 'android-37' in: C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to generate a Build Scan (Powered by Develocity).
> Get more help at https://help.gradle.org.

BUILD FAILED in 17s
]
stdout[

> Configure project :launcher
WARNING: The option setting 'android.builtInKotlin=false' is deprecated.
The current default is 'true'.
It will be removed in version 10.0 of the Android Gradle plugin.
WARNING: The option setting 'android.enableJetifier=true' is deprecated.
The current default is 'false'.
It will be removed in version 10.0 of the Android Gradle plugin.

> Configure project :unityLibrary
Variant 'debug', will keep symbols in binaries for:
  'libunity.so'
  'libil2cpp.so'
  'libmain.so'
Variant 'release', symbols will be stripped from binaries.

> Configure project :launcher
Variant 'debug', will keep symbols in binaries for:
  'libunity.so'
  'libil2cpp.so'
  'libmain.so'
Variant 'release', symbols will be stripped from binaries.

> Configure project :unityLibrary:GooglePlayGamesManifest.androidlib
WARNING: minSdkVersion (26) is greater than targetSdkVersion (16) for variant "debug". Please change the values such that minSdkVersion is less than or equal to targetSdkVersion.
WARNING: minSdkVersion (26) is greater than targetSdkVersion (16) for variant "release". Please change the values such that minSdkVersion is less than or equal to targetSdkVersion.
WARNING: We recommend using a newer Android Gradle plugin to use compile SDK version 37.0

This Android Gradle plugin (9.0.0) was tested up to compile SDK version 36.1.

You are strongly encouraged to update your project to use a newer
Android Gradle plugin that has been tested with compile SDK version 37.0.

If you are already using the latest version of the Android Gradle plugin,
you may need to wait until a newer version with support for compile SDK version 37.0 is available.

For more information refer to the compatibility table:
https://d.android.com/r/tools/api-level-support

To suppress this warning, add/update
    android.suppressUnsupportedCompileSdk=37.0
to this project's gradle.properties.
Observed package id 'platforms;android-37.0' in inconsistent location 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0-2' (Expected 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0')
Observed package id 'platforms;android-37.0' in inconsistent location 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0-2' (Expected 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0')
Observed package id 'platforms;android-37.0' in inconsistent location 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0-2' (Expected 'C:\Program Files\Unity\Hub\Editor\6000.5.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-37.0')

[Incubating] Problems report is available at: file:///D:/My_Documents/UnityProjects/TidalWaveTom/Library/Bee/Android/Prj/IL2CPP/Gradle/build/reports/problems/problems-report.html

Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/9.1.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/Android/Command.cs:221)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/Android/Command.cs:159)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg, System.Text.Encoding inputEncoding) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/Android/Command.cs:117)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/Android/AndroidJavaTools.cs:115)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.String[] extraArguments, System.Action`1[T] progress) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/Android/Gradle.cs:271)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.String[] extraArguments, System.Action`1[T] progress) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/Android/Gradle.cs:280)
UnityEditor.Android.PostProcessor.Tasks.TasksCommon.RunGradleTask (UnityEditor.Android.PostProcessor.PostProcessorContext context, System.String workingDirectory, System.String taskName, System.String[] extraArguments, UnityEditor.Android.PostProcessor.IPostProcessorTask owner, UnityEditor.Android.PostProcessor.ProgressHandler progress) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/PostProcessor/Tasks/TasksCommon.cs:71)
UnityEditor.Android.PostProcessor.Tasks.TasksCommon.RunLauncherGradleTask (UnityEditor.Android.PostProcessor.PostProcessorContext context, System.String taskName, System.String[] extraArguments, UnityEditor.Android.PostProcessor.IPostProcessorTask owner, UnityEditor.Android.PostProcessor.ProgressHandler progress) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/PostProcessor/Tasks/TasksCommon.cs:54)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/PostProcessor/Tasks/BuildGradleProject.cs:100)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/PostProcessor/AndroidPostProcessor.cs:112)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

Really frustrating, as I didn’t have these problems when I updated my Unity and Play Games Plugin versions for the same reason last year. Really hoping someone can help with this, as I was hoping to release an update for my game later in the Summer too.

Thanks in advance.

That would be mobile purchasing and mobile advertising in a nutshell!

Here’s my cribsheet… good luck!

How to troubleshoot build failures:

Obviously, if there is actionable data, clues or information within any of the errors, fix those problems. Each error entry may have more information than can fit in the console log so select each error and read the expanded view below it. Check the Editor log as well.

If that gives you nothing worthwhile (look to Google! You’re never the first one!), then…

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 misconfigured or incorrectly-installed or incompatible third-party libraries such as Firebase or AdMob or IronSource.

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:

Circa July 2022 here have been reports of Unity’s installer failing to install the Android Tools.

Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022 (edited on August 23, 2023 to include Android SDK 33…) (and again for SDK34):

And for Android SDK35, my own experiences and success:

After the Unity-CVE incident I installed Unity2022.3.62f2 and also Android SDK36 and … IT JUST WORKED! I did remove all previous Android SDKs before doing that though.

Android Gradle errors and other related stuff:

More Android SDK35 stuff:

Check if all you need to do is to update the min/max SDK version numbers in Player settings. This seems most likely because the old project would have that number lower than before. Though a +10 jump is big, unless you have been updating that project several times now without adapting the min SDK version and thus eventually passed that threshold.

It should probably be set to:
Min SDK=26
Max SDK=37
Target SDK=26-37 (your call, but don’t make it uninformed as it determines what devices will be able to run your app)

Also good idea to test is creating a blank project with 6.5 and try building that for Android as is. If that works, you know the toolchain isn’t the problem and you can compare both Player settings to see where your current project differs.

My Min and Max SDK are already set to the lowest and highest, respectively, even before I ran that build. I’ve even set both to 37 just for a test, but still get the same error.

By looking at the SDK path on the gradle error it seems that Gradle is trying to find something in:

C:\\Program Files\\Unity\\Hub\\Editor\\6000.5.7f1\\Editor\\Data\\PlaybackEngines\\AndroidPlayer\\SDK\\platforms\\android-37.0-2

Can you delete the android-37.0-2 folder and try again?

This error is also quite telling, android-37 is no longer a valid folder for the Platforms SDK, since Google chang it to 37.0 starting on 36.1:

Failed to find target with hash string 'android-37' in: C:\\Program Files\\Unity\\Hub\\Editor\\6000.5.7f1\\Editor\\Data\\PlaybackEngines\\AndroidPlayer\\SDK

Deleting the 37.0-2 folder didn’t change anything. Still get the exact same error.

I’m starting to think there’s a bug where Unity is comparing the minimum API’s level to the Target API level’s version number, instead of the level.

How’s that blank project build test going? :wink: