Gradle won't build

Knock knock.
Who’s there?
Gradle.
Gradle who?
Gradle build failed. See the Console for details.

So suddenly my android game doesn’t want to build, due to the gradle build failing.
Here are the three errors:

Configure project :launcher
WARNING:The option setting ‘android.aapt2FromMavenOverride=C:\Program Files\Unity\Hub\Editor\2022.3.47f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\34.0.0\aapt2.exe’ is experimental.

Configure project :unityLibrary
Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘maven2’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenLocal’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘BintrayJCenter’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenRepo’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘maven2’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenLocal’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘BintrayJCenter’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenRepo’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘maven2’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenLocal’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘BintrayJCenter’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenRepo’ was added by build file ‘unityLibrary\build.gradle’
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See Command-Line Interface
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Error 2:

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘C:\Users\PeterGriffin\Downloads\Naamloos\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\build.gradle’ line: 53

  • What went wrong:
    A problem occurred evaluating project ‘:unityLibrary’.

Could not find method targetSdkVersion() for arguments [33] on extension ‘android’ of type com.android.build.gradle.LibraryExtension.

  • 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 get full insights.

BUILD FAILED in 7s

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

And error 3:

CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2022.3.47f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Program Files\Unity\Hub\Editor\2022.3.47f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.5.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”

Environment Variables:
PROCESSOR_ARCHITECTURE = AMD64
AMPLITUDE_API_KEY_YELLOWBUCKET_DEV = 48835b4d1f5e342aefe5f016324d296a
ANDROID_NDK_ROOT = C:\Program Files\Unity\Hub\Editor\2022.3.47f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
DriverData = C:\Windows\System32\Drivers\DriverData
USERDOMAIN = Wompwomp
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
COMPUTERNAME = Wompwomp
DEBUG_ENV_VAR = UnityHub
LOGONSERVER = \Wompwomp
AMPLITUDE_TOKEN_GREENBUCKET_PROD = ZpUcbAdZXJYzNSoHsAWtL_s_JppwWid9
PUBLIC = C:\Users\Public
ProgramData = C:\ProgramData
SESSIONNAME = Console
AMPLITUDE_TOKEN_YELLOWBUCKET_PROD = UYDQtPOw83dIfVy3SrW5oMyo7ru4PRkV
ALLUSERSPROFILE = C:\ProgramData
RegionCode = EMEA
SystemRoot = C:\WINDOWS
windir = C:\WINDOWS
AMPLITUDE_API_KEY_REDBUCKET_DEV = 46b8b46515e7632fc42a504b72e05fd0
ProgramFiles(x86) = C:\Program Files (x86)
ProgramW6432 = C:\Program Files
OS = Windows_NT
PROCESSOR_IDENTIFIER = AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD
HOMEPATH = \Users\PeterGriffin
AMPLITUDE_TOKEN_REDBUCKET_DEV = U4PSN7S7PuYVRODivvdcFwbu8R6IHGqa
EFC_3248 = 1
CHROME_CRASHPAD_PIPE_NAME = \.\pipe\crashpad_1832_SBKZRWWHMUVVOBEW
PROCESSOR_LEVEL = 23
platformcode = KV
CommonProgramFiles = C:\Program Files\Common Files
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2022.3.47f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
USERDOMAIN_ROAMINGPROFILE = Wompwomp-HP-ENVY
TEMP = C:\Users\PeterGriffin\AppData\Local\Temp
ProgramFiles = C:\Program Files
CommonProgramW6432 = C:\Program Files\Common Files
AMPLITUDE_TOKEN_YELLOWBUCKET_DEV = wKi8foVigDditGFvmZewRFWsEbX9Y0YO
AMPLITUDE_API_KEY_GREENBUCKET_DEV = 3ded2a762163603391a425f688f990c8
AMPLITUDE_API_KEY_REDBUCKET_PROD = ca12bb461ea96f9bdf5df4ded7d52994
VBOX_HWVIRTEX_IGNORE_SVM_IN_USE = 1
HOMEDRIVE = C:
AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21
USERNAME = PeterGriffin
OneDrive = C:\Users\PeterGriffin\OneDrive
AMPLITUDE_API_KEY_YELLOWBUCKET_PROD = e03a9bbe92dc38a88cdb068d24c65b46
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
AMPLITUDE_TOKEN_REDBUCKET_PROD = jTIgKs5KTZOjiqEEVdZFbgo_VRhABduL
OculusBase = C:\Program Files\Oculus
NUMBER_OF_PROCESSORS = 6
AMPLITUDE_TOKEN_GREENBUCKET_DEV = 84H2gMm_FJzhr3mBaX1lM1JVukmCM7d9
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_DEV = client-wbjHYrmeSR87GmWOE7LDpf7sUySOIKHm
AMPLITUDE_API_KEY_GREENBUCKET_PROD = c86fea37a9e1d3f0878b96e15b111c7c
ComSpec = C:\WINDOWS\system32\cmd.exe
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
PROCESSOR_REVISION = 6001
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_PROD = client-zH8Y7OK1i331EKuG77C6UxN8ygcM6LzS
TMP = C:\Users\PeterGriffin\AppData\Local\Temp
SystemDrive = C:
OnlineServices = Online Services
AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
OneDriveConsumer = C:\Users\PeterGriffin\OneDrive
SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017
APPDATA = C:\Users\PeterGriffin\AppData\Roaming
Path = C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Oculus\Support\oculus-runtime;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\Git\cmd;C:\Users\PeterGriffin\AppData\Local\Microsoft\WindowsApps;
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
LOCALAPPDATA = C:\Users\PeterGriffin\AppData\Local
USERPROFILE = C:\Users\PeterGriffin
WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3

stderr[

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘C:\Users\PeterGriffin\Downloads\Naamloos\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\build.gradle’ line: 53

  • What went wrong:
    A problem occurred evaluating project ‘:unityLibrary’.

Could not find method targetSdkVersion() for arguments [33] on extension ‘android’ of type com.android.build.gradle.LibraryExtension.

  • 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 get full insights.

BUILD FAILED in 7s
]
stdout[

Configure project :launcher
WARNING:The option setting ‘android.aapt2FromMavenOverride=C:\Program Files\Unity\Hub\Editor\2022.3.47f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\34.0.0\aapt2.exe’ is experimental.

Configure project :unityLibrary
Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘maven2’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenLocal’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘BintrayJCenter’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenRepo’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘maven2’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenLocal’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘BintrayJCenter’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenRepo’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘maven2’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenLocal’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘BintrayJCenter’ was added by build file ‘unityLibrary\build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘MavenRepo’ was added by build file ‘unityLibrary\build.gradle’

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

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

See Command-Line Interface
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <6ba85f9f66d640eca843ad5ffbffa8ec>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <6ba85f9f66d640eca843ad5ffbffa8ec>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <6ba85f9f66d640eca843ad5ffbffa8ec>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <6ba85f9f66d640eca843ad5ffbffa8ec>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action1[T] progress) (at <6ba85f9f66d640eca843ad5ffbffa8ec>:0)
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.Action`1[T] progress) (at <6ba85f9f66d640eca843ad5ffbffa8ec>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <6ba85f9f66d640eca843ad5ffbffa8ec>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <6ba85f9f66d640eca843ad5ffbffa8ec>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Please help me I tried almost everything I could find on the internet.

Please don’t use the 2D tag unless you’re asking about 2D as this puts it in the 2D product area and your question is nothing to do with 2D features.

Please use tags that relate to the question you’re asking.

I’ll remove the tag for you.

Thanks.

^ ^ ^ This is another fantastic teeshirt idea!!!

Sorry to hear about your Gradle… see link at the bottom of this massive blurb of text about builds in general, there’s some Gradling to be had in there.

Gradle, gradle, gradle…

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.

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 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:

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):

Android Gradle errors and other related stuff: