Gradle build failed (Solved)

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 Command-Line Interface
42 actionable tasks: 15 executed, 27 up-to-date
]
exit code: 1

1 Like

Did you ever figure out a solution for this?
thank you!

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

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.
112292: [Unity] ERROR: Note: Recompile with -Xlint:deprecation for details.
ERROR: FAILURE: Build failed with an exception.
ERROR: Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
ERROR: > 1 exception was raised by workers:
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)
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)
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)
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)
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)
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)

plenty of com.google.gson.

Says solved, but i don’t see a solution!
am i missing something?

I got the same errors, HELP!
Mobile\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.

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:

  • Go to Edit->Project Settings->Player->Publishing settings->Tick Custom Properties Gradle Template
  • Go to the newly generated gradleTemplate.properties and add these lines to the top:

android.useAndroidX=true
android.enableJetifier=true

10 Likes

You will get the same error oddly if the password on the keystone file is incorrect… So do check that…

12 Likes

Thanks for pointing me out. This was the case for me.

1 Like

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

1 Like

This was my case as well.
The error message is extremely misleading.

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

thank you sir it solved my issue custom gradle properties was the issue

1 Like

I found a solution! It’s all about the wrong password in key.store :stuck_out_tongue:

I also suffered for many days, but the solution turned out to be simple:rage:

1 Like

Also check this workaround (Maybe this is caused by an incompatibility between Android Build Tools version 31.0.0 and the Unity build system)

2 Likes

Thanks. This solved my problem.

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

This was the case for me as well.

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

1 Like

I’m just clicked here and fixed.

1 Like

Deleting my Library folder fixed it for me as well

1 Like