Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug CommandInvokationFailure: Gradle build failed.

Discussion in 'Android' started by BaranKYNC, Sep 6, 2023.

  1. BaranKYNC

    BaranKYNC

    Joined:
    May 23, 2022
    Posts:
    6
    Hello guys.

    Hello, I'm getting an error as follows in my game I've developed for Android. My editor version is 2021.3.10f1. I changed the java version tried jdk-8u202, jdk-8u191. I changed the editor version 2022.3.8f1 I tried jdk11 and it didn't work.
    I changed the Gradle version, I tried 6.1.1 and it still didn't work (recommended versions in unity docs)
    I installed the sdk ndk build tools with android studio, it still didn't work. Assets >
    I did External Dependency Manager > Android resolver > Force Resolve but it still didn't change. No matter what I do, I still get this error. Please help.

    My error:

    CommandInvokationFailure: Gradle build failed.
    C:\Program Files\Java\jdk1.8.0_202\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2021.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

    Environment Variables:
    USERDOMAIN = DESKTOP-FOVMNKA
    ProgramFiles = C:\Program Files
    TMP = C:\Users\baran\AppData\Local\Temp
    PROCESSOR_ARCHITECTURE = AMD64
    PROCESSOR_REVISION = 0802
    OneDriveConsumer = C:\Users\baran\OneDrive
    OS = Windows_NT
    CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_7068_XBBVZTPFIKIDHFQV
    PROCESSOR_IDENTIFIER = AMD64 Family 23 Model 8 Stepping 2, AuthenticAMD
    AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
    USERPROFILE = C:\Users\baran
    JAVA_HOME = C:\Program Files\Java\jdk1.8.0_202
    CommonProgramFiles = C:\Program Files\Common Files
    DriverData = C:\Windows\System32\Drivers\DriverData
    ComSpec = C:\WINDOWS\system32\cmd.exe
    LAUNCH_DARKLY_CLIENT_TOKEN = 60a7e30fafc7e60e33446283
    PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
    PUBLIC = C:\Users\Public
    SystemRoot = C:\WINDOWS
    HEAP_CLIENT_TOKEN = 1717415662
    NUMBER_OF_PROCESSORS = 12
    WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3
    JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
    DEBUG_ENV_VAR = UnityHub
    ProgramW6432 = C:\Program Files
    TEMP = C:\Users\baran\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\Java\jdk1.8.0_191\bin;C:\Users\baran\AppData\Local\Microsoft\WindowsApps;;C:\Users\baran\AppData\Local\Programs\Microsoft VS Code\bin
    USERNAME = baran
    COMPUTERNAME = DESKTOP-FOVMNKA
    USERDOMAIN_ROAMINGPROFILE = DESKTOP-FOVMNKA
    PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    SystemDrive = C:
    ALLUSERSPROFILE = C:\ProgramData
    SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017
    HEAP_CLIENT_TOKEN_STAGING = 3786794399
    windir = C:\WINDOWS
    AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21
    CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
    APPDATA = C:\Users\baran\AppData\Roaming
    PROCESSOR_LEVEL = 23
    CommonProgramW6432 = C:\Program Files\Common Files
    ProgramFiles(x86) = C:\Program Files (x86)
    SESSIONNAME = Console
    LOGONSERVER = \\DESKTOP-FOVMNKA
    LOCALAPPDATA = C:\Users\baran\AppData\Local
    HOMEPATH = \Users\baran
    LAUNCH_DARKLY_CLIENT_TOKEN_STAGING = 60a7e30fafc7e60e33446282
    HOMEDRIVE = C:
    OneDrive = C:\Users\baran\OneDrive
    ProgramData = C:\ProgramData
    ORIGINAL_XDG_CURRENT_DESKTOP = undefined


    stderr[

    FAILURE: Build failed with an exception.

    * What went wrong:
    Value 'C:\Program Files\Java\jdk1.8.0_191' given for org.gradle.java.home Gradle property is invalid (Java home supplied is invalid)

    * 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.

    * Get more help at https://help.gradle.org
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    ]
    stdout[

    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <20241dc5e40b49439203197892d272d8>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <20241dc5e40b49439203197892d272d8>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <20241dc5e40b49439203197892d272d8>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <20241dc5e40b49439203197892d272d8>:0)
    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 <20241dc5e40b49439203197892d272d8>: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 <20241dc5e40b49439203197892d272d8>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <20241dc5e40b49439203197892d272d8>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <20241dc5e40b49439203197892d272d8>:0)
    Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
    UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <20241dc5e40b49439203197892d272d8>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <20241dc5e40b49439203197892d272d8>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <20241dc5e40b49439203197892d272d8>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <20241dc5e40b49439203197892d272d8>:0)
    UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <99feab6f3db6407493924fe4a179a95b>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)
     
  2. boris1709

    boris1709

    Joined:
    Dec 17, 2018
    Posts:
    3
    I have the exact same problem right now, for multiple days stuck on it. Switching to Unity 2022 and gradle 7.2 did not fix the problem either.

    Uninstalling the Mobile Notifications package is the only way to get my project to build on the android phone at the moment, you might be having that same issue.

    Edit:

    I fixed the program by just getting a blank project, which was able to properly build. Then just drag the Assets folder into the new blank project and rebuild everything.
     
    Last edited: Sep 7, 2023
  3. BaranKYNC

    BaranKYNC

    Joined:
    May 23, 2022
    Posts:
    6
    Thanks bro its works