Help about building apk file problems..!

Dear all,

i m just trying to learnd C# and unity. i m building a simple game by following a tutorial. the problem is that while i m trying to build apk file i m getting some error which i have no idea about :slight_smile: please hel.

first error:
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Java\jdk-9.0.4\bin\java.exe -classpath “C:\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.4’.

  • 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.Action1 progress, System.String error) UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action1 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)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

Second Error:
Build completed with a result of ‘Failed’
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

Third Error:
UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0020e] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:181
at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00065] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:88
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

I’m having the same problem here. using a Mac IOS and trying to export to my Android mobile. The difference in the message I get in the Console is only this part:

  • What went wrong:
    A problem occurred configuring root project ‘gradleOut’.

Could not resolve all files for configuration ‘:classpath’.
Could not find com.android.tools.build:gradle:4.0.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.jar
Required by:
project :

I’m thinking about changing the content of this gradle/lib folder from 4.0.1 to the 2.3.0, since I didn’t find the build/gradle/4.0.1 location listed above.

I found the solution somewhere searched in google by downgrading the JDK version 9 to JDK version 8. It’s weird to think to the latest JDK doesn’t work in unity.

jdk-8u172-windows-x64.exe It solved my problem.