Search Unity

CommandInvokationFailure: Gradle build failed.

Discussion in 'Editor & General Support' started by kleinubingfelipe, Sep 24, 2018.

  1. kleinubingfelipe

    kleinubingfelipe

    Joined:
    Aug 7, 2018
    Posts:
    19
    trying to build my first game.. after hours of googling i found no solution..
    Any help?

    CommandInvokationFailure: Gradle build failed.
    C:/Program Files/Java/jdk1.8.0_181\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:
    A problem occurred configuring root project 'gradleOut'.
    > No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED in 27s
    ]
    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)
     
  2. bilal1993arikan

    bilal1993arikan

    Joined:
    Jul 26, 2013
    Posts:
    7
    Same error (Unity 2018.2.3f)
     
  3. WalterPalladino

    WalterPalladino

    Joined:
    Oct 24, 2016
    Posts:
    2
    Same here with the Unity last version: 2018.2.10f1
     
    pablogonzalezguerra likes this.
  4. jcbhmmn

    jcbhmmn

    Joined:
    Oct 4, 2014
    Posts:
    16
    same issue
     
  5. Realitykiller

    Realitykiller

    Joined:
    Aug 22, 2018
    Posts:
    1
    Same here.
     
  6. lynnlaker

    lynnlaker

    Joined:
    Sep 28, 2018
    Posts:
    1
    same here
     
  7. innovativesrinivasan

    innovativesrinivasan

    Joined:
    Aug 1, 2018
    Posts:
    1
    Any solutions on this
     
  8. jcbhmmn

    jcbhmmn

    Joined:
    Oct 4, 2014
    Posts:
    16
    I tried removing Android NDK as another forum post suggested, but run into a new error:

    Code (CSharp):
    1. CommandInvokationFailure: Gradle build failed.
    2. C:\Program Files\Java\jdk1.8.0_181\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2018.2.0f2\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.2.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"
    3.  
    4. stderr[
    5.  
    6. FAILURE: Build failed with an exception.
    7.  
    8. * What went wrong:
    9. Execution failed for task ':packageRelease'.
    10. > Requested array size exceeds VM limit
    11.  
    12. * Try:
    13. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    14.  
    15. * Get more help at https://help.gradle.org
    16.  
    17. BUILD FAILED in 1m 3s
    18. ]
    19. stdout[
    20. :preBuild UP-TO-DATE
    21. :preReleaseBuild
    22. :compileReleaseAidl
    23. :compileReleaseRenderscript
    24. :checkReleaseManifest
    25. :generateReleaseBuildConfig
    26. :prepareLintJar
    27. :generateReleaseResValues
    28. :generateReleaseResources
    29. :mergeReleaseResources
    30. :createReleaseCompatibleScreenManifests
    31. :processReleaseManifest
    32. :splitsDiscoveryTaskRelease
    33. :processReleaseResources
    34. :generateReleaseSources
    35. :javaPreCompileRelease
    36. :compileReleaseJavaWithJavac
    37. :compileReleaseNdk NO-SOURCE
    38. :compileReleaseSources
    39. :lintVitalRelease
    40. :mergeReleaseShaders
    41. :compileReleaseShaders
    42. :generateReleaseAssets
    43. :mergeReleaseAssets
    44. :transformClassesWithPreDexForRelease
    45. :transformDexWithDexForRelease
    46. :mergeReleaseJniLibFolders
    47. :transformNativeLibsWithMergeJniLibsForRelease
    48. :processReleaseJavaRes NO-SOURCE
    49. :transformResourcesWithMergeJavaResForRelease
    50. :validateSigningRelease
    51. :packageRelease FAILED
    52. 25 actionable tasks: 25 executed
    53. ]
    54. exit code: 1
    55. UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    56. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    57. UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
    58. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
    59. Rethrow as GradleInvokationException: Gradle build failed
    60. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
    61. UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    62. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    63. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    64.  
     
  9. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,231
    @jcbhmmn looks like Gradle is running out of memory for some reason. is your game exceptionally large? or do you have any huge files that are included in your APK ?
     
  10. seniorquico

    seniorquico

    Joined:
    Mar 26, 2018
    Posts:
    1
    This was my top search result on Google... for posterity:

    I encountered this same error in both Unity 2018.2.10f1 and 2017.4.12f1. This error was somehow caused by the installation of a newer NDK. I had installed NDK r18 via Android Studio's SDK manager tool. I simply renamed the folder of the latest NDK, and my Unity builds began to work again.

    To confirm, my Unity preferences were setup with the explicit path to the NDK r13b that Unity appears to require. Nonetheless, the presence of the newer NDK in my SDK folder somehow triggered this error. What's frustrating for me was this things worked for some period of time... then just suddenly stopped.
     
  11. Surfninja

    Surfninja

    Joined:
    Nov 11, 2013
    Posts:
    5
    @seniorquico I am confused by your statement, were you able to solve the issue by renaming the NDK folder?

    If so can you please explain more. I am trying to work with Oculus Go if it makes any difference.

    I have NDK installed in Android Studio version 18.0.5002713

    Unity \ External Tools \ SDK: C:\AndroidSDK \\ JDK: C:\Program Files (x86)\Android\jre \\ NDK: C:\AndroidSDK\
    ndk-bundle

    Are you referring to the folder inside C:\AndroidSDK\ndk-bundle?

    I get the same error as the thread poster @kleinubingfelipe except with this below:
    Code (CSharp):
    1. BUILD FAILED in 5s
    2. ]
    3. stdout[
    4. Starting a Gradle Daemon, 2 stopped Daemons could not be reused, use --status for details
    5.  
    6. Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
    7. Use '--warning-mode all' to show the individual deprecation warnings.
    8. See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings
    9. ]
    10. exit code: 1
    11. UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    12. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    13. UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
    14. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
    15. Rethrow as GradleInvokationException: Gradle build failed
    16. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
    17. UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    18. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    19. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
  12. Surfninja

    Surfninja

    Joined:
    Nov 11, 2013
    Posts:
    5
    To everyone still stuck on this problem, here is how I worked around the error above.
    BUILD SETTINGS > BUILD SYSTEM > INTERNAL (not GRADLE)

    Finally able to get my Scene into my Oculus GO. Good Luck!
     
    hhung516 and ashrafksalim1 like this.
  13. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,231
    Using the "Internal" build system is not advised. It's obsolete and will be gone in the near future.
    Gradle is the proper way to build for Android going forward.
     
    IgorAherne likes this.
  14. Surfninja

    Surfninja

    Joined:
    Nov 11, 2013
    Posts:
    5
    Well it was the only way to get my system working. I am open to alternatives @liortal
     
  15. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,231
    Not familiar with this type of error, sorry. Would be very hard to diagnose without looking at it myself.
     
  16. kleinubingfelipe

    kleinubingfelipe

    Joined:
    Aug 7, 2018
    Posts:
    19
    My solution guys: Reinstall all JDK and android studio and set new ambient variables in windows.. after all that it works normally... its not a unity problem for me
     
    MinhDao likes this.
  17. ziad10a

    ziad10a

    Joined:
    Mar 21, 2014
    Posts:
    16
    Hey appearently I started getting this issue when I set the android-sdk ENVI_PATH in my windows
    So if you have NDK isntalled in your SDK folder it'll automatically use that instead of the pre-set path you have inside unity.

    Just delete the NDK package from within the SDK and it'll be fine, anyway Unity requires r13b so the inner NDK isn't needed when using unity.
     
  18. jcbhmmn

    jcbhmmn

    Joined:
    Oct 4, 2014
    Posts:
    16
    My project is about 3gb (Contains a 360 video file that is 2.9 gb). I have created 360 video android builds in the past without issue...it seems to be a result of the latest unity version or the android skd...Is there some sort of size limitation for an Android build?
     
  19. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,231
    Are you using "split binary" (e.g: OBB files) ? i am not sure you;'re able to pack an .apk in those sizes without an app expansion (OBB)
     
  20. HiepEldest

    HiepEldest

    Joined:
    Aug 26, 2018
    Posts:
    1
    I just get same issue. Set Scripting Backend to Il2CPP and it's working for me
     
    Last edited: Oct 6, 2018
  21. jcbhmmn

    jcbhmmn

    Joined:
    Oct 4, 2014
    Posts:
    16
    I deleted the 360 video file from my assets and was able to build successfully. Of course it does not function as a 360 video app any longer, but I guess there are some solutions for streaming from the cloud? To recap, I have the latest version of Unity installed, the latest version of Android studio, but using build tools 27.0.3. And I have removed the NDK.
     
  22. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    94
    This worked for me as well! Thank you very much for sharing.
     
  23. milindu

    milindu

    Joined:
    Dec 19, 2016
    Posts:
    1
    This solution work for my .. Thanks ziadantar90
     
    Adnimistrator likes this.
  24. Burljon

    Burljon

    Joined:
    Jun 28, 2017
    Posts:
    2
    Worked for me as well, using 2018.14f1. Everything was working fine until I updated to the latest Android studio. Root cause, the latest NDK from Android does not have mips64el-linux-android. Unity points to r15b, but gradle build still uses the latest NDK if it's present. You have to delete it.
     
  25. Paradon1

    Paradon1

    Joined:
    Nov 11, 2018
    Posts:
    1
    Went into Android studio and unselected NDK from the SDK tools menu.
     
    Trigger likes this.
  26. VirtualCastle

    VirtualCastle

    Joined:
    Dec 29, 2015
    Posts:
    1
    Set the scripting from MONO to IL2CPP, that's it!.
     
    funscience and hisanao_saab like this.
  27. tkyaji

    tkyaji

    Joined:
    Nov 16, 2015
    Posts:
    2
    When building gradle builds on Android, the `ndk.dir` is not set in `local.properties` during output.
    I was able to build successfully by adding the following script to the top of the `mainTemplate.gradle` like so:


    def properties = new Properties()
    def propFile = project.rootProject.file('local.properties')
    properties.load(propFile.newDataInputStream())
    properties.setProperty("ndk.dir", "<NDK_PATH>/android-ndk-r13b")
    properties.store(propFile.newWriter(), null)
     
    Last edited: Nov 28, 2018
    aenerv7 and Avocco like this.
  28. umkhan93

    umkhan93

    Joined:
    Jan 3, 2018
    Posts:
    4
    Uninstalling NDK from the SDK directory solved the problem for me. If your project doesn't require NDK uninstall it
     
  29. umkhan93

    umkhan93

    Joined:
    Jan 3, 2018
    Posts:
    4

    Attached Files:

  30. Coresi7

    Coresi7

    Joined:
    Mar 10, 2017
    Posts:
    13
    Oh, Gradle is absolutely NOT a good idea when we use CI build and the build machine disconnect with the internet for security reason, thus makes the gradle failed to connect Internet.
    Not saying about the problem that it does not follow the Unity's NDK preference and ALWAYS use the latest NDK updated and maintained by Android Studio.
    For all the reasons, no matter what happened to build systems, we will stick to Internal instead of Gradle except all of the problems are solved.
     
  31. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,231
    The "internal" system is going away, and you better move to Gradle to build your projects.
     
  32. Avocco

    Avocco

    Joined:
    Feb 2, 2015
    Posts:
    13
    this solve our issue, thanks!
     
  33. Tortuap

    Tortuap

    Joined:
    Dec 4, 2013
    Posts:
    46
    That was my issue too, while having already NDK 13 installed. But forgot about the NDK v18 I had previously installed.
    I uninstalled the NDK v18 from Android Studio (Tools -> Android -> SDK Manager, then tab SDK Tools, unchecked NDK v18.1.blabla).
     
    marceloscmsamsung likes this.
  34. atalantus

    atalantus

    Joined:
    Jan 17, 2016
    Posts:
    8
    You saved my life!
     
  35. elhispano

    elhispano

    Joined:
    Jan 23, 2012
    Posts:
    52
    Thanks! This works for me
     
    yehielc likes this.
  36. marceloscmsamsung

    marceloscmsamsung

    Joined:
    Dec 14, 2017
    Posts:
    1
    THANKS! WORKED!
     
  37. michaelRF

    michaelRF

    Joined:
    Dec 2, 2016
    Posts:
    1
    That absolutly helped me after a lot of reinstalling and update and ....
    For me it was already enough to just rename the folder of the ndk-bundle
    Thank you very much for this tip.
     
  38. koyanghi

    koyanghi

    Joined:
    Aug 28, 2012
    Posts:
    1

    It works well! Thank you very much!!
    This problem happened when I installed new version of Android studio.
    Before that, Nothing happened.
     
  39. HungPark

    HungPark

    Joined:
    Feb 28, 2017
    Posts:
    50
    I resolved the same issue as this(Gradle Build Failed) by unchecking NDK from SDK Tools of Android Studio as following path.

    SDK manager( the second icon from the right on the Tool bar of Android Studio) -> Appearance & Behavior ->
    System Settings -> Android SDK -> SDK tools -> unchecked NDK

    I hope this will be helpful.
     
    Last edited: Mar 4, 2019
  40. AndrewKoval

    AndrewKoval

    Joined:
    Mar 6, 2016
    Posts:
    1
    Thanks! This worked for me too!
     
  41. ShaourKhan

    ShaourKhan

    Joined:
    Aug 1, 2018
    Posts:
    1
    where can i find this mainTemplate.gradle, i am new to unity
     
  42. __Rob__

    __Rob__

    Joined:
    Sep 10, 2015
    Posts:
    2
    To find your mainTemplate.gradle file, do the following.

    Within Unity's top menu:
    1. Edit > Project Settings > Player to open the Player Settings in the inspector
    2. The inspector should have tabs for each supported platform. Click on the little android robot to select your Android settings.
    3. Click on the Publishing Settings section to expand it
    4. In the Build section, ensure that Build System is set to Gradle
    5. If you check the Custom Gradle Template checkbox, you will see the path to the mainTemplate.gradle file in your project.
     
  43. kiwibrook

    kiwibrook

    Joined:
    Mar 16, 2015
    Posts:
    1
    This worked for me! Thanks.
     
  44. ashrafksalim1

    ashrafksalim1

    Joined:
    Jun 17, 2018
    Posts:
    1
    Thanks For that
     
  45. yehielc

    yehielc

    Joined:
    Oct 1, 2018
    Posts:
    1
    Worked for me!! tnx!!!
     
  46. KingKong320

    KingKong320

    Joined:
    Mar 2, 2018
    Posts:
    21
    Trying to create android app bundle in unity 2017.4.32f1 ,but having this sort of error,PLease help me out.
    Thankyou
     

    Attached Files: