- Home /
Unity error during android apk build : Gradle build Failed
I am trying to build an apk file with Unity 2017.30f3 (64bit) on a Windows 10 PC. I get the following errors in the console: -ERROR 1 CommandInvokationFailure: Gradle build failed. C:/Program Files/Java/jdk1.8.0_152\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"
-ERROR 2 Error building Player: 2 errors
-ERROR 3 Build completed with a result of 'Failed' UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
-ERROR 4 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 UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
I tried to solve as per suggetions from different forums but have not been able to solve it. I have replaced the tools in the sdk with old tools, tried with jdk 8 instead of 9, restarted unity, reimported the project, but the problem persists. Been stuck at this for a long time. Please folks, all help is appreciated. Thanks.
Answer by Nick62 · Feb 20, 2018 at 06:50 PM
Try to use gradle 2.3.0 instead of 2.1.0 or 4.0.1 You need to edit file mainTemplate.gradle in project folder \Assets\Plugins\Android\
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}