"Gradle Build Failed" when building for Android
I was trying to build my AR game for Android. I fixed an error claiming that unity could not find my SDK by using the solution in this thread, and it seemed to work as the process got farther before giving an error. I get this error when trying to build and run now (it gets through detecting my phone plugged in and seems to do most of the building then the error is thrown at the end):
Gradle build failed. See console for details
In the console, I get this:
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Java\jdk-9.0.1\bin\java.exe -classpath "D:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"
stderr[
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9.0.1'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
]
stdout[
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
What does this mean? What do I do to fix this? Any help would be greatly appreciated
Follow this Question
Related Questions
Unity 2019.2 can't locate ndk or use ndk 0 Answers
Unity remote 0 Answers
Is there a way to setup Android environment and Android Sdk without unity hub!? 1 Answer
Invalid JDK home selected (Mac) 1 Answer
Android SDK problem 1 Answer