Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Gradle build fails

Discussion in 'Android' started by vladk, Jul 13, 2018.

  1. vladk

    vladk

    Joined:
    Jul 10, 2008
    Posts:
    167
    Hi, trying to build an Android project on 2018.2.0f2 with Google Services and Facebook SDK. Using Gradle.

    Here is what it gives me when trying to build on Android:
    On 2018.1.6 everything was building fine.

    Code (CSharp):
    1. CommandInvokationFailure: Gradle build failed.
    2. C:/Program Files/Java/jdk1.8.0_171\bin\java.exe -classpath "D:\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 com.android.tools.build:gradle:3.0.1.
    12.      Searched in the following locations:
    13.          https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
    14.          https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
    15.          https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
    16.          https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
    17.      Required by:
    18.          project :
    19.  
    20. * Try:
    21. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    22.  
    23. * Get more help at https://help.gradle.org
    24.  
    25. BUILD FAILED in 3s
    26. ]
    27. stdout[
    28.  
    29. ]
    30. exit code: 1
    31. UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    32. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    33. UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
    34. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
    35. Rethrow as GradleInvokationException: Gradle build failed
    36. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
    37. UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    38. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    39. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    40.  
     
    Ali_V_Quest and neonblitzer like this.
  2. NinjaCat

    NinjaCat

    R&D Minion Unity Technologies

    Joined:
    Aug 22, 2013
    Posts:
    69
    SohamMalakar and hiagotruta like this.
  3. vladk

    vladk

    Joined:
    Jul 10, 2008
    Posts:
    167
    Wait, why is it going into internet to make a build? Isn't it suppose to make it locally? I don't have access to that file via my standard connection.
    Oh, and no, I don't use any custom templates.
    Can I download that file and just hook it up somewhere locally?
     
    Last edited: Jul 13, 2018
    neonblitzer likes this.
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you elaborate "standard connection"? Then you ask if you can download the file. You mean from another computer?
     
  5. vladk

    vladk

    Joined:
    Jul 10, 2008
    Posts:
    167
    umm... I live in place, all IP-addresses of which was banned by Google. I.e. I can reach some google services like google play, developer console or those library servers only via VPN.

    I still don't understand why I'm building just fine in 2018.1.7f1 , but in 2018.2 - it fails. Come on, guys, how is that even normal you're trying to download something to just make a build? What if I'm working without any internet connection?
     
    Last edited: Jul 14, 2018
    neonblitzer likes this.
  6. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,165
    You still need to download Android SDK and NDK to make the builds. You also need internet to activate the editor, so "no internet" doesn't really work; it's needed for initial setup.

    What if you had a custom build.gradle with a custom android plugin version? Then you can't avoid using internet at all.

    The plugin download happens once, and then the plugin gets cached somewhere in gradle cache - so please get a connection somehow once, and it should work then.

    Running Unity Editor without Internet connection may be a valid use case, for example for CI environment. However initial setup is still needed, including the components I mentioned before. Sorry it didn't work for you, looks like Google moved their newest plugins to own servers instead of Maven central.
     
    Last edited: Jul 16, 2018
    HunnyMalik likes this.
  7. vladk

    vladk

    Joined:
    Jul 10, 2008
    Posts:
    167
    Yes, both Android SDK and NDK are installed. No, I don't use custom scripts for gradle. I repeat, IT BUILDS FINE IN 2018.1.7. :( Sad...
     
    neonblitzer likes this.
  8. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,165
    2018.2 uses a newer plugin version than 2018.1. For 2018.1, it's on maven central; for 2018.2, it's on google servers.
     
  9. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    This is still not an answer. WHAT MUST BE DONE? I see alot puff and flubbering with technical diatribe. What must be done to even get a clue about where to start? Deleting directories? Come on.
    The three areas are Unity version, gradle version, and android dev version. When the project used to build correctly now it doesn't points to something external.
    Now how does one get to the google servers? Give instructions, links and document files. If you got the answer then give complete directions as to where exactly to go. I see too many spouting an answer without supportive links.
     
    Last edited: Dec 31, 2018
    neonblitzer likes this.
  10. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,165
    @giantkilleroverunity3d thank you for asking.

    We have fixed the issue in latest Unity versions. Please make sure to stay on the latest patch release.

    If you are using a custom gradle template, make sure it has

    Code (CSharp):
    1.         google()
    2.         jcenter()
    and not the other way around.
     
  11. hybridAli

    hybridAli

    Joined:
    Jan 4, 2016
    Posts:
    8
    I am having same issue with 2019.1. I am using NDK and SDK as installed from Unity Hub and template has both
    Code (CSharp):
    1. google()
    2. jcenter()
     
  12. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,165
    Please submit a bug report and attach a project to the case. Post the case number here. Thanks!
     
  13. mojtabashamsabadi

    mojtabashamsabadi

    Joined:
    Nov 14, 2018
    Posts:
    2
    I have a similar problem when add .jar plugin in prject error:could not resolve all files for configuration ' lintclasspath'
    I am using custom gradle template file
     
  14. Dewald_Bodenstein

    Dewald_Bodenstein

    Joined:
    Feb 27, 2014
    Posts:
    6
    Sorry for waking this old thread. I'm getting a similar issue but for me it looks like the resources are trying to download over a non SSL connection. I have upgraded to Unity 2019.3.10f1.

    Here's the first:
    A problem occurred configuring project ':launcher'.
    > Could not resolve all artifacts for configuration ':launcher:classpath'.
    > Could not download kotlin-stdlib-jdk8.jar (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.21)
    > Could not get resource 'http://jcenter.bintray.com/org/jetb...lib-jdk8/1.3.21/kotlin-stdlib-jdk8-1.3.21.jar'.
    > Could not GET 'http://jcenter.bintray.com/org/jetb...lib-jdk8/1.3.21/kotlin-stdlib-jdk8-1.3.21.jar'. Received status code 403 from server: Forbidden

    When accessing the URL I get:
    403 JCenter is only available over HTTPS

    Edit: I can download manually... Where would I place it then?
     
  15. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,165
    @Dewald_Bodenstein your error message is quite clear: gradle is trying to download the kotlin package using http, when something (java?) only allows to use https. Are you using the embedded OpenJDK or an external JDK?

    As on the manual question, there should be some place in the gradle cache - try googling that or exploring your hard drive, I honestly don't remember the filesystem locations.
     
    Cz_im_bored and CandraWi like this.
  16. Dewald_Bodenstein

    Dewald_Bodenstein

    Joined:
    Feb 27, 2014
    Posts:
    6
    I was using the embedded OpenJDK. Reinstalled Unity multiple times from scratch through the Unity Hub.

    I ended up downloading Unity, using the Download Assistant, and each external library (Android SDK, NDK, Gradle and the JDK) and linking to them instead, and this has worked.
     
  17. Mehrdad995

    Mehrdad995

    Joined:
    Jul 17, 2013
    Posts:
    46
    I had the same issue, it has nothing to do with unity however I think they could get around it and handle it better.
    It's all due to changing the Internal build to Gradle.
    For me I was getting this error <Could not find com.android.tools.lint:lint-gradle:26.4.0.>
    so according to Unity log I was needed these two files (lint-gradle-26.4.0.jar) and (lint-gradle-26.4.0.pom).
    the place which the first file gets downloaded to for me is:
    C:\Users\Mehrdad\.gradle\caches\modules-2\files-2.1\com.android.tools.lint\lint-gradle\26.4.0\37a4329b9cba9f4c316cb084ca74da988cee7225\lint-gradle-26.4.0.jar
    and for the second file is:
    C:\Users\Mehrdad\.gradle\caches\modules-2\files-2.1\com.android.tools.lint\lint-gradle\26.4.0\c48020f557d89cc7168c88efce0084914ef8bb4\lint-gradle-26.4.0.pom
    please note that there is a hashed folder in above adresses which may be different for each client so you might just not be able to copy paste the path.
     
  18. SohamMalakar

    SohamMalakar

    Joined:
    May 10, 2019
    Posts:
    1
    It worked just fine. Thanks
     
  19. frozengineer

    frozengineer

    Joined:
    Jun 25, 2020
    Posts:
    6
    for me it's these files needed:
    builder-3.4.0.jar
    bundletool-0.7.2.jar
    gradle-3.4.0.jar
    protos-26.4.0.jar

    since unity cant download them, i manually did but i don't know where to put them instead. My download speed for other unrelated things is better (3MBps) but when i downloaded these files, the speed goes 20kbps max instead with many disconnects. I assume it's same in unity.

    Code (CSharp):
    1. CommandInvokationFailure: Gradle build failed.
    2. C:/Users/Admin/Documents/unity/backup/OpenJDK\bin\java.exe -classpath "C:\Users\Admin\Documents\unity\backup\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
    3.  
    4. stderr[
    5.  
    6. FAILURE: Build failed with an exception.
    7.  
    8. * What went wrong:
    9. A problem occurred configuring project ':launcher'.
    10. > Could not resolve all artifacts for configuration ':launcher:classpath'.
    11.    > Could not download builder.jar (com.android.tools.build:builder:3.4.0)
    12.       > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.4.0/builder-3.4.0.jar'.
    13.          > Read timed out
    14.  
    15. * Try:
    16. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    17.  
    18. * Get more help at https://help.gradle.org
    19.  
    20. BUILD FAILED in 14m 15s
    21.  
    22.  

    please anyone, what should i do?
     
    Sufyan_123 likes this.
  20. mhmad2212

    mhmad2212

    Joined:
    Sep 12, 2019
    Posts:
    5
    hello
    go to Assets\Plugins\Android and remove all content then
    in unity editor in Assets menu go to Play Service Resolver(or external play resolver) >Android Resolver>Resolve
    now everyThing is oK!
     
    Hizan_Games likes this.
  21. reguig-abdo

    reguig-abdo

    Joined:
    Apr 23, 2017
    Posts:
    4
    I am having the same problem. Did you find any solution?
     
  22. PHL1

    PHL1

    Joined:
    Jul 25, 2017
    Posts:
    29
    I can't build either and getting a similar error. what can i do to fix this?
    unity version: 2020.3.03f1Personal
    Code (CSharp):
    1. CommandInvokationFailure: Gradle build failed.
    2. C:\Program Files\Unity\Hub\Editor\2020.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2020.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.6.4.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleDebug"
    3.  
    4. stderr[
    5.  
    6. FAILURE: Build failed with an exception.
    7.  
    8. * What went wrong:
    9. A problem occurred configuring project ':launcher'.
    10. > Could not resolve all artifacts for configuration ':launcher:classpath'.
    11.    > Could not find databinding-compiler-common.jar (androidx.databinding:databinding-compiler-common:3.6.0).
    12.      Searched in the following locations:
    13.          https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler-common/3.6.0/databinding-compiler-common-3.6.0.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. Run with --scan to get full insights.
    17.  
    18. * Get more help at https://help.gradle.org
    19.  
    20. BUILD FAILED in 3s
    21. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    22. ]
    23. stdout[
    24. Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
    25. ]
     
    CandraWi likes this.
  23. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    I was given a solution that reportedly works by a commercial dev and that is build the apk then sideload. Not the best but oh well. I have not tried this as each problem needs too much resources when there of other problems that have the current focus.
     
  24. PHL1

    PHL1

    Joined:
    Jul 25, 2017
    Posts:
    29
    what do you mean by sideload? can you explain more please?
     
  25. PHL1

    PHL1

    Joined:
    Jul 25, 2017
    Posts:
    29
    I finally got the build.
    i deleted the .gradle folder which i think it's not necessary to do that but no harm cause it will be generated again by gradle and then used a good internet connection also a good vpn then tried to build again and finally after days i got the apk.
     
    nbg_yalta likes this.
  26. peterfiveeight

    peterfiveeight

    Joined:
    Jun 24, 2013
    Posts:
    9
    Where did you delete this folder from please?
     
  27. Personuo

    Personuo

    Joined:
    Mar 19, 2014
    Posts:
    122
    never success!
     
  28. PHL1

    PHL1

    Joined:
    Jul 25, 2017
    Posts:
    29
    it's in " C:\Users\(your username) "
     
  29. Cz_im_bored

    Cz_im_bored

    Joined:
    Jun 7, 2021
    Posts:
    2
    Yeah, I'm having the same problem now. I'm using an external jdk. Im kinda new to unity. So I'd like to know. For any new project, the first time we build, do we need an internet connection for the gradle to work?