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 failed (Solved)

Discussion in 'Editor & General Support' started by vygo07, Apr 10, 2020.

  1. vygo07

    vygo07

    Joined:
    Jan 8, 2019
    Posts:
    4
    Any idea why this error? Thanks!

    CommandInvokationFailure: Gradle build failed.
    C:/Program Files/Java/jdk1.8.0_131\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2020.1.0a21\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

    stderr[
    Note: D:\HOBO\HOBO\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    D8: Program type already present: android.support.annotation.PluralsRes

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':launcher:transformClassesAndResourcesWithR8ForRelease'.
    > com.android.tools.r8.CompilationFailedException: Compilation failed to complete

    * Try:
    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.

    * Get more help at https://help.gradle.org

    BUILD FAILED in 33s
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    ]
    stdout[
    > Task :unityLibrary:preBuild UP-TO-DATE
    > Task :launcher:preBuild UP-TO-DATE
    > Task :unityLibrary:preReleaseBuild UP-TO-DATE
    > Task :unityLibrary:checkReleaseManifest UP-TO-DATE
    > Task :launcher:extractProguardFiles UP-TO-DATE
    > Task :launcher:prepareLintJar UP-TO-DATE

    > Task :unityLibrary:processReleaseManifest
    D:\HOBO\HOBO\Temp\gradleOut\unityLibrary\src\main\AndroidManifest.xml:4:3-27:17 Warning:
    application@android:icon was tagged at AndroidManifest.xml:4 to replace other declarations but no other declaration present

    > Task :unityLibrary:compileReleaseAidl NO-SOURCE
    > Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
    > Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
    > Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
    > Task :unityLibrary:generateReleaseResValues UP-TO-DATE
    > Task :unityLibrary:generateReleaseResources UP-TO-DATE
    > Task :unityLibrary:packageReleaseResources UP-TO-DATE
    > Task :unityLibrary:generateReleaseRFile UP-TO-DATE
    > Task :unityLibrary:prepareLintJar UP-TO-DATE
    > Task :unityLibrary:generateReleaseSources UP-TO-DATE
    > Task :launcher:preReleaseBuild
    > Task :launcher:compileReleaseAidl NO-SOURCE
    > Task :launcher:compileReleaseRenderscript NO-SOURCE
    > Task :launcher:checkReleaseManifest UP-TO-DATE
    > Task :launcher:generateReleaseBuildConfig UP-TO-DATE
    > Task :launcher:generateReleaseSources UP-TO-DATE
    > Task :launcher:mainApkListPersistenceRelease UP-TO-DATE
    > Task :launcher:generateReleaseResValues UP-TO-DATE
    > Task :launcher:generateReleaseResources UP-TO-DATE
    > Task :unityLibrary:javaPreCompileRelease

    > Task :unityLibrary:compileReleaseJavaWithJavac

    > Task :unityLibrary:bundleLibCompileRelease UP-TO-DATE
    > Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
    > Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
    > Task :unityLibrary:compileReleaseShaders UP-TO-DATE
    > Task :unityLibrary:generateReleaseAssets UP-TO-DATE
    > Task :launcher:mergeReleaseResources UP-TO-DATE
    > Task :launcher:javaPreCompileRelease UP-TO-DATE
    > Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
    > Task :launcher:processReleaseManifest
    > Task :launcher:processReleaseResources
    > Task :launcher:compileReleaseJavaWithJavac UP-TO-DATE
    > Task :launcher:compileReleaseSources UP-TO-DATE
    > Task :unityLibrary:packageReleaseAssets
    > Task :unityLibrary:processReleaseJavaRes NO-SOURCE
    > Task :unityLibrary:bundleLibResRelease UP-TO-DATE
    > Task :unityLibrary:bundleLibRuntimeRelease UP-TO-DATE
    > Task :unityLibrary:mergeReleaseConsumerProguardFiles UP-TO-DATE
    > Task :unityLibrary:mergeReleaseJniLibFolders
    > Task :unityLibrary:transformNativeLibsWithMergeJniLibsForRelease
    > Task :unityLibrary:transformNativeLibsWithStripDebugSymbolForRelease
    > Task :launcher:lintVitalRelease
    > Task :launcher:mergeReleaseShaders UP-TO-DATE
    > Task :launcher:compileReleaseShaders UP-TO-DATE
    > Task :launcher:generateReleaseAssets UP-TO-DATE
    > Task :unityLibrary:transformNativeLibsWithIntermediateJniLibsForRelease
    > Task :launcher:mergeReleaseAssets
    > Task :launcher:validateSigningRelease UP-TO-DATE
    > Task :launcher:signingConfigWriterRelease UP-TO-DATE
    > Task :launcher:processReleaseJavaRes NO-SOURCE
    > Task :launcher:transformResourcesWithMergeJavaResForRelease

    > Task :launcher:transformClassesAndResourcesWithR8ForRelease FAILED
    R8 is the new Android code shrinker. If you experience any issues, please file a bug at
    https://issuetracker.google.com, using 'Shrinker (R8)' as component name. You can
    disable R8 by updating gradle.properties with 'android.enableR8=false'.
    Current version is: 1.4.77 (build b74371231cb896b02f83285efb055b7c00ff64d8 from go/r8bot (luci-r8-ci-archive-0-eqqf)).


    Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
    Use '--warning-mode all' to show the individual deprecation warnings.
    See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
    42 actionable tasks: 15 executed, 27 up-to-date
    ]
    exit code: 1
     
    goldcloud144 likes this.
  2. AaronD1230

    AaronD1230

    Joined:
    Apr 18, 2020
    Posts:
    2
    Did you ever figure out a solution for this?
    thank you!
     
  3. Dazo1985

    Dazo1985

    Joined:
    Mar 13, 2019
    Posts:
    26
    Also got this


    Temp/gradleOut/unityLibrary/src/main/java/com/unity3d/player/UnityPlayerActivity.java uses or overrides a deprecated API.


    Note: Recompile with -Xlint:deprecation for details.

    ERROR: FAILURE: Build failed with an exception.

    2019.3.11
    Using Firebase and Gamedock SDK

    It appeared after adding the Firestore Firebase package



    All build Errors isolated


    Code (CSharp):
    1.  
    2. 112264: [Unity] ERROR: Note: /BUILD_PATH/smeet-gmbh.lost-legacies.lost-leagcies-android/Temp/gradleOut/unityLibrary/src/main/java/com/unity3d/player/UnityPlayerActivity.java uses or overrides a deprecated API.
    3. 112292: [Unity] ERROR: Note: Recompile with -Xlint:deprecation for details.
    4. ERROR: FAILURE: Build failed with an exception.
    5. ERROR: Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
    6. ERROR: > 1 exception was raised by workers:
    7. ERROR:   java.lang.RuntimeException: Duplicate class com.google.gson.DefaultDateTypeAdapter found in modules classes.jar (io.gamedock.sdk:gamedock-sdk:3.8.1) and gson-2.7.jar (com.google.code.gson:gson:2.7)
    8. ERROR:   Duplicate class com.google.gson.ExclusionStrategy found in modules classes.jar (io.gamedock.sdk:gamedock-sdk:3.8.1) and gson-2.7.jar (com.google.code.gson:gson:2.7)
    9. ERROR:   Duplicate class com.google.gson.FieldNamingPolicy found in modules classes.jar (io.gamedock.sdk:gamedock-sdk:3.8.1) and gson-2.7.jar (com.google.code.gson:gson:2.7)
    10. ERROR:   Duplicate class com.google.gson.FieldNamingStrategy found in modules classes.jar (io.gamedock.sdk:gamedock-sdk:3.8.1) and gson-2.7.jar (com.google.code.gson:gson:2.7)
    11. ERROR:   Duplicate class com.google.gson.Gson found in modules classes.jar (io.gamedock.sdk:gamedock-sdk:3.8.1) and gson-2.7.jar (com.google.code.gson:gson:2.7)
    12. ERROR:   Duplicate class com.google.gson.JsonArray found in modules classes.jar (io.gamedock.sdk:gamedock-sdk:3.8.1) and gson-2.7.jar (com.google.code.gson:gson:2.7)
    13.  
    14. plenty of com.google.gson.
     
  4. samshosho

    samshosho

    Joined:
    Apr 12, 2010
    Posts:
    370
    Says solved, but i don't see a solution!
    am i missing something?
     
  5. Baciu_Marius

    Baciu_Marius

    Joined:
    Sep 27, 2019
    Posts:
    1
    I got the same errors, HELP!
    Mobile\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
     
  6. DungDajHjep

    DungDajHjep

    Joined:
    Mar 25, 2015
    Posts:
    173
    https://github.com/facebook/facebook-sdk-for-unity/issues/386
    https://forum.unity.com/threads/cant-build-with-multidex-enabled.773348/


    For anyone looking for solution.
    You have to move your
    implementation 'androidx.multidex:multidex:2.0.1'
    and
    multiDexEnabled true
    from mainTemplate.gradle to launcherTemplate.gradle and it should work.

    You should activate these files first here in the Project Setting->Player->Publishing Settings


    I solved it in two steps for Unity 2019.3.11f1:

    1. Go to Edit->Project Settings->Player->Publishing settings->Tick Custom Properties Gradle Template
    2. Go to the newly generated gradleTemplate.properties and add these lines to the top:
    android.useAndroidX=true
    android.enableJetifier=true
     
  7. Boliver0482

    Boliver0482

    Joined:
    Oct 19, 2019
    Posts:
    45
    You will get the same error oddly if the password on the keystone file is incorrect... So do check that...
     
  8. WaqasGameDev

    WaqasGameDev

    Joined:
    Apr 17, 2020
    Posts:
    118
    Thanks for pointing me out. This was the case for me.
     
  9. karam89

    karam89

    Joined:
    Aug 23, 2015
    Posts:
    10
    Thank you very much, you saved me

    this was the case of me
    I had to move those lines from mainTemplate.gradle to launcherTemplate.gradle
     
    DungDajHjep likes this.
  10. Menion-Leah

    Menion-Leah

    Joined:
    Nov 5, 2014
    Posts:
    189
    This was my case as well.
    The error message is extremely misleading.
     
  11. krzychuwr1_unity

    krzychuwr1_unity

    Joined:
    Jul 28, 2019
    Posts:
    13
    Thank you, I've wasted half an hour on this error, bumping it for others to see, it was a typo in keystore password for me as well
     
  12. ahsan1995

    ahsan1995

    Joined:
    Nov 21, 2017
    Posts:
    3
    thank you sir it solved my issue custom gradle properties was the issue
     
    DungDajHjep likes this.
  13. AbaiK_

    AbaiK_

    Joined:
    Aug 18, 2021
    Posts:
    1
    I found a solution! It's all about the wrong password in key.store :p

    I also suffered for many days, but the solution turned out to be simple:mad:
     
    Lorrak likes this.
  14. sath

    sath

    Joined:
    Mar 25, 2013
    Posts:
    13
    goldcloud144 and AnderX003 like this.
  15. AnderX003

    AnderX003

    Joined:
    Feb 14, 2018
    Posts:
    3
  16. batuhan_isik

    batuhan_isik

    Joined:
    Oct 14, 2020
    Posts:
    1
    I faced with this problem in 2020.3.16f1 unity version ,

    When I upgraded my facebook sdk to 11.0.0 version , I successfully built my ios project but couldn't build on android.
    I tried various solutions which are in unity forums or etc.

    I solved like that ,
    -Close the unity
    -Delete temp folder under your project folder
    -Delete Facebook sdk and facebook sdk meta folder
    -Open Unity , If you face some errors in launchining to unity let ignore them.
    -Import facebook sdk unity package.
    -Enter the facebook sdk settings values
    -You are good to go
     
  17. leumasinkwater

    leumasinkwater

    Joined:
    May 31, 2019
    Posts:
    1
    This was the case for me as well.
     
  18. CarvalhoLO

    CarvalhoLO

    Joined:
    Nov 29, 2017
    Posts:
    8
    I solved this issue deleting my lybraries folder (from my game project folder) and also deleting the resolve plugin>android folder. At least i can build with these deleats but i dont know if is enought to publish an android game in google play store
     
    AsterieRevancha likes this.
  19. ertbaran

    ertbaran

    Joined:
    Feb 22, 2019
    Posts:
    11
    I'm just clicked here and fixed.

    upload_2022-4-1_4-51-27.png
     
    JRaph likes this.
  20. warrenLD

    warrenLD

    Joined:
    Jul 2, 2019
    Posts:
    9
    Deleting my Library folder fixed it for me as well
     
  21. JazzCat-9

    JazzCat-9

    Joined:
    Sep 1, 2015
    Posts:
    16
    I just now had this problem with a pair of new test scenes w/ Unity 2020.3.30f1.

    I'm not 100% certain this isn't "voodoo computing" but my problem for both scenes was that I wasn't connected to the Internet for their first Android builds.

    I hooked up to the 'Net prior to building each after several Gradle fails with each, and after a bit longer of a wait on "Building Gradle Project", each in turn built fine -- even after disconnecting my workstation from the network.
     
    Lorrak likes this.
  22. atu93vn

    atu93vn

    Joined:
    Mar 28, 2022
    Posts:
    1
    In my case, I don't know why but I just think that my computer dont have any anti-virus programs cause the issue, then after I installed one, I successfully built it! DAMM
     
  23. AshyB

    AshyB

    Joined:
    Aug 9, 2012
    Posts:
    189
    I had same problem, it was because I did not have a project keystore created/used.
     
    Lorrak likes this.
  24. colourcrisis

    colourcrisis

    Joined:
    Apr 12, 2018
    Posts:
    4
    Okay so how I solved the issue was to go to project settings, other options and set the android API to a minimum of API 30. Basically, the latest right now is Android 13. Don't bother setting an API to something really old. Set the range from minimum to target to as close as Android 13 as possible. Set your project keys. Build. It may ask you to upgrade your Android SDK, if so, say yes. It should build correct from here on.