Gradle Build Failed [CommandInvokation Failure]

It can’t even build a blank project. I’m new to using unity. Pls help me.

Here is the error-

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

Environment Variables:
EFC_9392_2775293581 = 1
RegionCode = APJ
USERDOMAIN = ATHARVA
ProgramFiles = C:\Program Files
TMP = C:\Users\Athar\AppData\Local\Temp
ChocolateyInstall = C:\ProgramData\chocolatey
PROCESSOR_ARCHITECTURE = AMD64
HOMEDRIVE = C:
PROCESSOR_REVISION = ba02
OS = Windows_NT
CHROME_CRASHPAD_PIPE_NAME = \.\pipe\crashpad_6132_SSTEYSOYDYGKDSJY
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 186 Stepping 2, GenuineIntel
MYSQL_INCLUDE = C:\Program Files\MySQL\MySQL Server 8.0\include
MYSQL_LIB = C:\Program Files\MySQL\MySQL Server 8.0\lib
USERPROFILE = C:\Users\Athar
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2022.3.60f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
IGCCSVC_DB = AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAkonLDsRN6k23FBfPGd6KmwQAAAACAAAAAAAQZgAAAAEAACAAAABmVbF22FurPgxnWn00QiTrAj6EfPcg9knAI00RCSQCXQAAAAAOgAAAAAIAACAAAADTdQ7nkbbFgg3LtKfsaM2N9BRwHtr24QRr7mucMLaUq2AAAACuz0vSgC/n0mUCy4bm32z7/IIykZn0ZK7y9eTpJZ115iu6owcMm0OEIECmXahBWLkTuxZRtO3FxgQTVuZnQlPBJDUsrj1iZLLeAm2jpZtMvIi5Li67U95hXO4p35ruTnVAAAAA4LAD55j85pVZNVu0bvGfOu7kkaCEsLD9i+pu9+QVzzKQvHYtRQxUtGDTCddt1PgM8cMRj4/0uu57Qd2YTwzE5A==
CommonProgramW6432 = C:\Program Files\Common Files
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\160\Tools\PowerShell\Modules
ANDROID_NDK_ROOT = C:\Program Files\Unity\Hub\Editor\2022.3.60f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
SystemRoot = C:\WINDOWS
platformcode = M7
NUMBER_OF_PROCESSORS = 12
ZES_ENABLE_SYSMAN = 1
ProgramW6432 = C:\Program Files
EFC_9392_1592913036 = 1
TEMP = C:\Users\Athar\AppData\Local\Temp
Path = C:\Program Files\Python313\Scripts;C:\Program Files\Python313;C:\Program Files\Common Files\Oracle\Java\javapath;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 (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Program Files\HP\OMEN-Broadcast\Common;C:\windows\IsmFiles;C:\MinGW\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\ProgramData\chocolatey\bin;C:\Users\Athar\AppData\Roaming\Python\Python313\Scripts;C:\Program Files\dotnet;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files (x86)\Microsoft SQL Server\160\Tools\Binn;C:\Program Files\Microsoft SQL Server\160\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files\Microsoft SQL Server\160\DTS\Binn;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\MySQL\MySQL Connector C++ 9.1\include;C:\Program Files\MySQL\MySQL Connector C++ 9.1\lib64;C:\Windows\System32\Wbem;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 app\NvDLISR;C:\Program Files\nodejs;C:\Program Files\Java\jdk-23\bin;C:\Program Files\Java\jdk-17\bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin;C:\Users\Athar\AppData\Local\Programs\Python\Launcher;C:\Users\Athar\AppData\Local\Microsoft\WindowsApps;C:\Users\Athar\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Athar.dotnet\tools;C:\Users\Athar\AppData\Local\GitHubDesktop\bin;C:\Users\Athar\AppData\Roaming\npm;C:\Program Files\Java\jdk-23\bin;C:\Program Files\Java\jdk-17\bin;
USERNAME = Athar
COMPUTERNAME = ATHARVA
EFC_9392_2283032206 = 1
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW
ALLUSERSPROFILE = C:\ProgramData
SystemDrive = C:
OnlineServices = Online Services
EFC_9392_1262719628 = 1
SESSIONNAME = Console
windir = C:\WINDOWS
ChocolateyLastPathUpdate = 133746524501469252
PUBLIC = C:\Users\Public
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\Athar\AppData\Roaming
OneDrive = C:\Users\Athar\OneDrive
PROCESSOR_LEVEL = 6
EFC_9392_3789132940 = 1
ProgramFiles(x86) = C:\Program Files (x86)
NVIDIAWHITELISTED = 0x01
ComSpec = C:\WINDOWS\system32\cmd.exe
LOGONSERVER = \ATHARVA
LOCALAPPDATA = C:\Users\Athar\AppData\Local
HOMEPATH = \Users\Athar
SHIM_MCCOMPAT = 0x810000001
USERDOMAIN_ROAMINGPROFILE = ATHARVA
ProgramData = C:\ProgramData
ORIGINAL_XDG_CURRENT_DESKTOP = undefined

stderr[

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘D:\Unity Projects\testApp\Library\Bee\Android\Prj\Mono2x\Gradle\build.gradle’ line: 6

  • What went wrong:
    Plugin [id: ‘com.android.application’, version: ‘7.4.2’, apply: false] was not found in any of the following sources:

  • Gradle Core Plugins (plugin is not in ‘org.gradle’ namespace)
  • Plugin Repositories (could not resolve plugin artifact ‘com.android.application:com.android.application.gradle.plugin:7.4.2’)
    Searched in the following repositories:
    Gradle Central Plugin Repository
    Google
    MavenRepo
  • 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 1s
]
stdout[

]
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:218)
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:157)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/Android/Command.cs:116)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/Android/AndroidJavaTools.cs:113) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action1[T] progress) (at /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/Android/Gradle.cs:226)
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 /home/bokken/build/output/unity/unity/PlatformDependent/AndroidPlayer/Editor/Managed/Android/Gradle.cs:231)
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:39)
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)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

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

Android Gradle errors and other related stuff:

Android SDK35 stuff:

I’ve tried reinstalling unity 6 and 2022 LTS versions but it still did not build for blank project