Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

CommandInvokationFailure: Gradle build failed.

Discussion in 'Android' started by neufoctobre, Oct 23, 2018.

  1. neufoctobre

    neufoctobre

    Joined:
    Jun 20, 2015
    Posts:
    85
    Hi Everyone !

    I got a problem using Unity 2018.2.13f1, I can't build and get an error.

    I checked many forum but don't find any answer to solve this problem.
    I already tried to reinstall JDK8. I tried to build with IL2CPP with JNK, and I also try to build with internal process but get unable to convert dex format.
    I always get the error and this is totally out of my skills.

    Does anyone have this problem and found the solution ?

    Thanks in advance :)

    Here is the error message :

    Code (CSharp):
    1. CommandInvokationFailure: Gradle build failed.
    2. C:\Program Files\Java\jdk1.8.0_191\bin\java.exe -classpath "C:\Program Files\Unity\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. A problem occurred configuring root project 'gradleOut'.
    10. > Could not resolve all files for configuration ':classpath'.
    11.    > Could not find intellij-core.jar (com.android.tools.external.com-intellij:intellij-core:26.0.1).
    12.      Searched in the following locations:
    13.          https://jcenter.bintray.com/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jar
    14.  
    15. * Try:
    16. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    17.  
    18. * Get more help at https://help.gradle.org
    19.  
    20. BUILD FAILED in 14s
    21. ]
    22. stdout[
    23. Starting a Gradle Daemon (subsequent builds will be faster)
    24. ]
    25. exit code: 1
    26. UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    27. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    28. UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
    29. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
    30. Rethrow as GradleInvokationException: Gradle build failed
    31. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
    32. UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    33. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    34. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    35.  
     
  2. Evaldas_Unity

    Evaldas_Unity

    Unity Technologies

    Joined:
    Jun 23, 2016
    Posts:
    64
    Greej likes this.
  3. Greej

    Greej

    Joined:
    Jun 13, 2017
    Posts:
    2
    This saved me. I spent several hours last night trying to figure out what was wrong. Reinstalled SDK, JDK. This worked for me.The link doesn't take me anywhere though...
     
  4. Evaldas_Unity

    Evaldas_Unity

    Unity Technologies

    Joined:
    Jun 23, 2016
    Posts:
    64
    Link should be up now. I literally reported this, and then went to forums so the system hadn't grabbed it yet : )
     
  5. Greej

    Greej

    Joined:
    Jun 13, 2017
    Posts:
    2
    Awesome. Thanks.
     
  6. thibouf

    thibouf

    Joined:
    Mar 17, 2017
    Posts:
    79
  7. veevoogames

    veevoogames

    Joined:
    Aug 12, 2018
    Posts:
    1
    same issue as what thibouf said, the workaround will work for some people, but as im using firebase and other plugins, i still get the error when i build, though the error will then say firebase cant find the path, please fix
     
    Last edited: Oct 25, 2018
  8. Evaldas_Unity

    Evaldas_Unity

    Unity Technologies

    Joined:
    Jun 23, 2016
    Posts:
    64
    Could you try doing this and letting me know if it helps? If it does I'll add it to the workaround. But do attempt this at your own risk. This is kinda for the 'adventurous' and people that can't wait for the proper fix (Which should be soon, already in QA).

    1. Go to unity install location (Let's say C:\Unity 2018.3.0b7\)
    2. Go Editor > Data > PlaybackEngines > AndroidPlayer > Tools > GradleTemplates
    3. Open libTemplate.gradle in a text editor (I prefer something like sublime, but do whatever works for you. I wouldn't recommend the default Notepad tho, it might frick up the line endings, not sure.)
    4. Switch line 3 and 4, so that google is on top.
     
  9. daniel-hall

    daniel-hall

    Joined:
    Sep 14, 2015
    Posts:
    2
  10. NamekGames

    NamekGames

    Joined:
    May 13, 2014
    Posts:
    10
    This works! No problem, build successful
     
  11. faustofonseca

    faustofonseca

    Joined:
    Oct 19, 2013
    Posts:
    10
    This is one combined with the original one is the solution!
     
  12. GainfulSage

    GainfulSage

    Joined:
    Apr 30, 2015
    Posts:
    86
    Is there an expected fix coming for cloud build that doesn't involve overriding the gradle build scripts...?
     
  13. Evaldas_Unity

    Evaldas_Unity

    Unity Technologies

    Joined:
    Jun 23, 2016
    Posts:
    64
    Sorry, I am not familiar with cloud builds. I assume they are using latest-ish versions (or what ever you select)?
    If so, using the 2017.4LTS (which was unaffected) or the upcoming 2018.2.15f1, 2018.3.0b10 or 2019.1.0a7 which have the fixes built should solve the problem.
     
  14. neufoctobre

    neufoctobre

    Joined:
    Jun 20, 2015
    Posts:
    85
    New problem with 2018.2.15f1 :
    What's going wrong with new unity ?!?! Unable to build any project since 2018 ...

    A problem occurred configuring root project 'gradleOut'.
    > No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android



    EDIT :
    Ok removing NDK tools solved the problem
     
    Last edited: Nov 12, 2018
  15. roshan090

    roshan090

    Joined:
    Mar 20, 2018
    Posts:
    30
    i am still stuck in error. please help me. i am doing all what you said. i am using an old version native plugin that is why i got this error. help me i am stuck in this error till now.
     

    Attached Files:

  16. ImanN16

    ImanN16

    Joined:
    Jul 25, 2017
    Posts:
    16
    i did every one of these but still can't build. what if i use internal build system instead?
    version :2018.2.11f1
     
  17. hiagotruta

    hiagotruta

    Joined:
    Jan 27, 2015
    Posts:
    4
    I still have the problem.
    Someone can help me?
     
  18. developerarreterra

    developerarreterra

    Joined:
    Oct 8, 2018
    Posts:
    8
    So, i had exactly the same problem and tried out a lot.
    What worked for me is to clear the .gradle folder inside my %Userfolder%
    When you build it will download the entire folder again (Unity will say it crashed, but Java is going strong). and after that I could build again!

    Hopes this works!
     
    Hanross and LAKSHAYMAVIA like this.
  19. abolfazl-tanha

    abolfazl-tanha

    Joined:
    Nov 22, 2015
    Posts:
    3
    Hello, i have same problem and i did all of works that you said in last posts but i couldn't t APK . My unity version is 2018.3.5 and i have all versions of Android SDK and JDK and NDK .

    Please Help me !!!
     
  20. abolfazl-tanha

    abolfazl-tanha

    Joined:
    Nov 22, 2015
    Posts:
    3
    Hello, i have same problem and i did all of works that you said in last posts but i couldn't t APK . My unity version is 2018.3.5 and i have all versions of Android SDK and JDK and NDK .

    Please Help me !!!
     
  21. femoreti

    femoreti

    Joined:
    May 9, 2014
    Posts:
    4
    OMG This saved me. Thanks!! Using Unity 2018.2.11f1
     
  22. Jackimaru

    Jackimaru

    Joined:
    Jun 10, 2019
    Posts:
    2
    This worked for me. Using latest 2019.1.6f1
     
  23. LAKSHAYMAVIA

    LAKSHAYMAVIA

    Joined:
    Aug 28, 2018
    Posts:
    26
    Thanks this works.
     
  24. gamingsauce

    gamingsauce

    Joined:
    Apr 21, 2018
    Posts:
    2
    Please guys tell me where is the %Userfolder%
     
  25. LAKSHAYMAVIA

    LAKSHAYMAVIA

    Joined:
    Aug 28, 2018
    Posts:
    26
    It will be inside
    C:\Users\USER_NAME
     
  26. roundham

    roundham

    Joined:
    Oct 28, 2014
    Posts:
    50
    Where is it for mac? Please help. Thanks
     
  27. LAKSHAYMAVIA

    LAKSHAYMAVIA

    Joined:
    Aug 28, 2018
    Posts:
    26
    Sorry roundham I don't know that. But I can give you a hint. In this folder we have all the current user related stuff like appdata , .android , .OtherSoftware. you have to search for that folder. or you can use software like this https://filehippo.com/download_everything/ for mac to find.
     
  28. sahadha777

    sahadha777

    Joined:
    Jul 14, 2018
    Posts:
    15
    How to integrate AR camera as a plugin. I am getting unity_android_bridge not found. without AR camera working fine
     
  29. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,559
    I'm using 2018.4.6 and it still has this issue, is there any update on this?
     
  30. Hanross

    Hanross

    Joined:
    Aug 11, 2018
    Posts:
    11
    only this works after cracking my mind for 8 hours Thank you very much you saved me
     
  31. TwillightDGaming

    TwillightDGaming

    Joined:
    Dec 8, 2018
    Posts:
    1
    i seem to have a build problem with il2cpp since unity version 2018.2 im now using version 2018.4.15 iv also tried to build with version 2019.2 but nothing its been three weeks for me now trying to build an apk the console give me the same issue like the others commandInvokationfailure: Gradle build failed
    C:/Program Files/Unity/Editor/Data/PlayEngine/AndroidPlayer/Tools/OpenJDK/Windows/bin/java.exe-classpath
    UnityEngine.GUIUtility:processEvent(Int32,IntPtr) at C:/builslave/unity/build/Modules/IMGUI/GUIUtility.cs:179
     
  32. mlongley_fb

    mlongley_fb

    Joined:
    Aug 21, 2019
    Posts:
    5
    Hey guys. This is still an issue.

    I was able to build, but now I can't for some reason..

    google is ontop of jcenter in the libTemplate gradle file.

    I have checked Custom Gradle Template.

    My JDK is set to 8.

    Still no luck with builds..

    (using Unity 2019.2.17)

    Help?
     
  33. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    585
  34. mlongley_fb

    mlongley_fb

    Joined:
    Aug 21, 2019
    Posts:
    5
    I would like to.. but I am unsure where to find this %Userfolder% ?

    It seems to just say %Userfolder% - and not a specific location on where one could actually find it..

    If I could get some additional info on where this %Userfolder% can be found - I will happily try out this fix..
     
  35. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    585
    It's just a home directory which is named as your user name. The location depends on the operating system. Take a look here https://en.wikipedia.org/wiki/Home_directory. For example if you are using WIndows 10, the directory will be in your main drive (named C by default) then "Users" and then your user name.
     
  36. mlongley_fb

    mlongley_fb

    Joined:
    Aug 21, 2019
    Posts:
    5
    Just tried this out. Issue is still persisting..

    :(
     
  37. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    585
    Does your error message look exactly like the one discussed in this thread?
    Code (CSharp):
    1. CommandInvokationFailure: Gradle build failed.
    2. C:\Program Files\Java\jdk1.8.0_191\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.2.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"
    3. stderr[
    4. FAILURE: Build failed with an exception.
    5. * What went wrong:
    6. A problem occurred configuring root project 'gradleOut'.
    7. > Could not resolve all files for configuration ':classpath'.
    8.    > Could not find intellij-core.jar (com.android.tools.external.com-intellij:intellij-core:26.0.1).
    9.      Searched in the following locations:
    10.          https://jcenter.bintray.com/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jar
    11.  
    If it just says "CommandInvokationFailure: Gradle build failed." it does not mean that it's the same issue, it could be anything else. This line just points out that building the project with Gradle has failed, the actual error is specified later in the same error message.
     
  38. cultzone

    cultzone

    Joined:
    Oct 20, 2019
    Posts:
    37
    we have same problem in the version 2017-2018-2019, but unknow the solutions... there many ways in web, but we dont see the problem??? IDE, JAVA or ANDROID?
     
  39. cultzone

    cultzone

    Joined:
    Oct 20, 2019
    Posts:
    37
    the template can be the problem??? oh god...
     
  40. lagzilajcsi

    lagzilajcsi

    Joined:
    Jan 19, 2020
    Posts:
    8
    my problem was just a bad password...
     
  41. blackcode101

    blackcode101

    Joined:
    Jul 10, 2020
    Posts:
    3
    @developerarreterra Thanks a lot for such a simple solution you saved my day, as i went through many portals and all those solutions mentioned in other portals seems to be a little difficult to understand and implement. I deleted the gradleout folder from my project inside the temp folder and also in the user folder .gradle folder and the build worked like a charm.... Thanks a again...
     
    cultzone likes this.
unityunity