CommandInvokationFailure: Gradle build failed.

Hello everyone. After update unity, i’ve got a some errors. I dont even know how to fix that.

CommandInvokationFailure: Gradle build failed.
C:/Program Files/Java/jdk1.8.0_171\bin\java.exe -classpath “D:\unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.2.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx2048m” “assembleRelease”

stderr[

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformDexWithDexForRelease’.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

And another one:

UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0021f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:187
at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:94
UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

i am already tried to downgrade SDK tools and JDK. It’s not working. I will be glad of any help.

Seems like you ran into the “64k method reference limit” problem on Android.

This usually means you have too many Android plugins in your project.

To solve this, you could simply disable/delete any Android libraries that are not needed. That is by far the simplest way to fix this issue.

If there’s nothing to delete, you can fix this by enabling multidex, or using pro proguard (or a mix of both).

NOTE: If you need any further help, please do know I provide a (paid) service for solving these kind of problems. Feel free to contact me via the link in my signature below.