transformClassesWithJarMergingForDebug FAILED issue with Gradle - android-gradle-plugin

I am fairly new at Android development and have been struggling to get a working build of an app I am working on.
I receive the following error after a build with Gradle:
:app:transformClassesWithJarMergingForDebug FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
android/support/v4/print/PrintHelper$1.class
I (think) I narrowed the issue down to multiple libraries using the same 'support-v4' module, but I'm not sure. I can provide more details. Thank you.

I fixed this by deleting .jar files that were duplicates.

Related

Forge 1.7.10 : Error while "gradlew setupDecompWorkspace"

I was trying to setup my modding environement and when i did 'gradlew setupDecompWorkSpace', this happen :
WARNING: You are using an unsupported version of ForgeGradle.
Please consider upgrading to ForgeGradle 4 and helping in the efforts to get old versions working on the modern toolchain.
See https://gist.github.com/TheCurle/fe7ad3ede188cbdd15c235cc75d52d4a for more info on contributing.
#################################################
ForgeGradle 1.2.2-g2ea0336
https://github.com/MinecraftForge/ForgeGradle
#################################################
Powered by MCP unknown
http://modcoderpack.com
by: Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
#################################################
:extractMcpData UP-TO-DATE
:getVersionJson
Unexpected reponse 403 from http://s3.amazonaws.com/Minecraft.Download/versions/1.7.10/1.7.10.json
:extractUserDev UP-TO-DATE
:genSrgs SKIPPED
:extractNatives UP-TO-DATE
:getAssetsIndex
Unexpected reponse 403 from https://s3.amazonaws.com/Minecraft.Download/indexes/1.7.10.json
:getAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':getAssets'.
> java.lang.NullPointerException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.862 secs
C:\Users\Dimitri\eclipse-workspace\forge-1.7.10-10.13.4.1614-1.7.10-src>
I've tried to change the gradle version into the gradle-wrapper.properties from 2.0 to 2.6, It just lasted longer.
I'm not a professional in this but my workaround when I had this problem was replacing forge gradle with anatawa12's fork. I think what happened was some urls changed in one of the forge updates and forge 1.7.10 wasn't considered in the change.
New gradle: https://github.com/anatawa12/ForgeGradle-1.2
How to fix the Problem Method 1:
Follow: https://github.com/anatawa12/ForgeGradle-example#how-to-replace-forgegradle-12-with-anatawa12s-fork
Edit Gradle wrapper to use gradle 4.4.1 or higher.
How to fix the Problem Method 2:
Download and use anatawa12's example gradle template (same commands for cmd):
https://github.com/anatawa12/ForgeGradle-example/archive/master.zip

Could not find support-v4.aar (com.android.support:support-v4:25.2.0)

i am running sample application...... I am using this module..... But i am getting error like this...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-google-analytics-bridge'.
> Could not find support-v4.aar (com.android.support:support-v4:25.2.0).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-v4/25.2.0/support-v4-25.2.0.aar
My module version is :"react-native-google-analytics-bridge": "^5.2.2"
Here is the screenshot:
In such cases of failure, sometimes the module linking doesn't go well.Please try to link the module manually as described in the link :https://github.com/idehub/react-native-google-analytics-bridge/wiki/Manual-installation
and/or try replace "support-v4:25.2.0" with compile 'com.android.support:support-v13:23.1.1'.
Location: Android/App/build.gradle

React native build getting failed :app:transformClassesWithDexForDebug

I am getting error while building react-native app using command react-native run-android
Error
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzav;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzav;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
:app:transformClassesWithDexForDebug FAILED
Failure
Build failed with an exception.
What went wrong
Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
Dependencies in android/app/build.gradle
delete android/app/build dir
This work for me.
As mentionned on this comment, you have to compile everything yourself. Add this in your android/app/build.gradle.
I don't know if you have the exact same problem, but everytime I ran in dex problems, this was the solution.
compile "com.google.android.gms:play-services-base:11.4.2"
compile "com.google.android.gms:play-services-base-license:11.4.2"
compile "com.google.android.gms:play-services-ads:11.4.2"
compile "com.google.android.gms:play-services-ads-lite:11.4.2"
compile "com.google.android.gms:play-services-ads-license:11.4.2"
compile "com.google.android.gms:play-services-analytics:11.4.2"
compile "com.google.android.gms:play-services-analytics-impl:11.4.2"
compile "com.google.android.gms:play-services-auth:11.4.2"
compile "com.google.android.gms:play-services-auth-base:11.4.2"
compile "com.google.android.gms:play-services-fitness:11.4.2"
compile "com.google.android.gms:play-services-gcm:11.4.2"
compile "com.google.android.gms:play-services-identity:11.4.2"
compile "com.google.android.gms:play-services-maps:11.4.2"
compile "com.google.android.gms:play-services-wallet:11.4.2"

Adding sub module to project causing gradle build failures in Android studio 3.0 with gradle version 4.1

I added sub module library vertical-stepper-form version 0.9.8, while I set dependency of this library on my app module. I was able to do it successfully.
I am using Android Studio 3.0 with gradle version 4.1, few of the classes in project are in kotlin and others in java
When I started gradle sync it gave me this error. The gradle is not building and showing below issues :
/*********************************/
Information:Gradle tasks [:vertical-stepper-form:generateDebugSources,
:vertical-stepper-form:generateDebugAndroidTestSources,
:vertical-stepper-form:mockableAndroidJar,
:app:generateInstallDebugSources,
:app:generateInstallDebugAndroidTestSources, :app:mockableAndroidJar]
D:\Devavrata\project/package/src/main/res/abc.xml Error:error:
attribute 'com.spireon.install:src' not found.
D:\Devavrata\AbcProject\abc-Android\app\build\intermediates\incremental\mergeInstallDebugResources\stripped.dir\layout\activity_main.xml
Error:attribute 'com.spireon.install:src' not found. Error:failed
linking file resources. Error:java.util.concurrent.ExecutionException:
java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details Error:java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error:
check logs for details Error:Execution failed for task
':app:processInstallDebugResources'.
Failed to execute aapt Information:BUILD FAILED in 24s Information:7 errors Information:0 warnings Information:See complete output in
console
/********************************/
What I have already tried :
I tried with changing import lines in xml also changing the android:src and srcCompat properties. Along with build/project cleaning and invalidating the cache.
Changing this line in gradle.properties
android.enableAapt2=false
Let me know if anyone has faced this issue

Multi-dimension Android project won't build - ProcessInfoBuilder$JavaProcessInfoImpl.getExecutable throws UnsupportedOperationException

i've got a rather large, multi-dimension Android app that i'm trying to upgrade from Dagger 1 to Dagger 2. i've made all the code changes i believe need to be made to support the upgrade, but now when i build the app i'm getting the following exception (during the transformClassesWithMultidexlistForXXX task):
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForMyFlavorAndDimensionDebug'.
> java.lang.UnsupportedOperationException (no error message)
* Try:
Run with --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithMultidexlistForMyFlavorAndDimensionDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
...(snip)...
Caused by: java.lang.UnsupportedOperationException
at com.android.ide.common.process.ProcessInfoBuilder$JavaProcessInfoImpl.getExecutable(ProcessInfoBuilder.java:349)
at com.android.build.gradle.internal.process.GradleProcessResult.buildProcessException(GradleProcessResult.java:74)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:49)
at com.android.builder.core.AndroidBuilder.createMainDexList(AndroidBuilder.java:1426)
...(snip)...
... 68 more
BUILD FAILED
Total time: 5 mins 5.179 secs
Stopped 0 compiler daemon(s).
digging into the source, ProcessBuilder.JavaProcessInfoImpl.getExecutable() simply throws an UnsupportedOperationException.
i'm using version 2.2.3 of the Android Gradle plug-in.
has anyone else run into this issue? have i done something in error to lead me down this path?
any thoughts or suggestions would be greatly appreciated!
*********************** UPDATE ***********************
i managed my way around this issue by downgrading from Dagger 2.8 —> 2.7.