Build causing java.util.zip.ZipException: duplicate entry error - java

Many seem to face this problem on Stackoverflow but non had the same problem and solution as I did.
"Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/collections/ArrayStack.class"
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.hey"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
multiDexEnabled true
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'commons-validator:commons-validator:1.4.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:design:25.3.1'
compile 'com.aurelhubert:ahbottomnavigation:2.0.6'
testCompile 'junit:junit:4.12'
//compile 'com.roughike:bottom-bar:2.3.1'
//compile 'com.android.support:design:26.0.0-alpha1'
}
I had this error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/collections/Buffer;
I fixed it using multiDexEnabled true but then the duplicate entry error showed up.
EDIT:
The problem was with commons-validator:commons-validator:1.4.1 but I'm still curious onto why and how to fix this error to still be able to use the validator.

If you're interested I solved the problem by replacing:
compile 'commons-validator:commons-validator:1.4.1'
with:
compile 'commons-validator:commons-validator:1.6'

Related

Error converting bytecode to dex with ProGuard

Getting this error without multidex:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process
And with multidex enabled:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.multidex.ClassReferenceListBuilder with arguments {C:\Users\pah-to-app\app\build\intermediates\multi-dex\debug\componentClasses.jar C:\Users\pah-to-app\app\build\intermediates\transforms\proguard\debug\jars\3\1f\main.jar}
Here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "AAA.AAAAAAA.AAAA"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'commons-io:commons-io:2.4'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.android:facebook-login:4.30.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
//compile 'com.android.support:support-v4:27.0.2'
compile 'com.android.support:support-vector-drawable:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Expecting your helpful suggestion to solve this issue. Thank you.
there is some .jar file in your project that use older version of google play services

Building an APK generates Error:Execution failed for task

When I try to build with my current gradle.build file, I get an error, then following that my gradle build.
Why is it causing this error?
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzaf$zzd.class
this is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.usmans.videodownloader"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
// glide
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.io.tools.android.ramiloif.folderchooser:folderchooser-dialog:1.0.6'
I don't know what is causing this. What can I do to solve this issue?
Change and exclude gms from facebook library.
compile ('com.facebook.android:audience-network-sdk:4.+'){
exclude group:"com.google.android.gms"
}
Then clean and rebuild your project.
Hope it works :)

Error: TranformException: java.util.zip.ZipException: duplicate entry:org/apache/http/HttpMessage.class error

In Android studio,for my preliminary test for my app, i build it. After gradle build success, when it is made to run, it throws an error,
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry: org/apache/http/HttpMessage.class
my app:build.gradle file is
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.nxtgn.jaunt"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
compile files('libs/android-async-http-1.4.9.jar')
compile files('libs/httpclient-4.3.3.jar')
compile files('libs/apache-httpcomponents-httpcore.jar')
}
its hard for me to figure out my mistake. Please help me where I went wrong.
In terminal you need to execute in root project folder
./gradlew clean

Android Studio Error while compiling an apk

I want to create my apk file for my project, but I get the following error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zznf;
This is my Build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.wp.fyriaxis"
minSdkVersion 17
targetSdkVersion 25
versionCode 5
versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.android.support:design:25.0.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.google.firebase:firebase-ads:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Your hint is that Multiple dex files define Lcom/google/android/gms
Meaning some of Google packages are conflicting.
The Firebase and Google play services versions must match

Android Studio Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

I am getting started with Parse and Facebook SDK in Android Studio. I have integrated it successfully but while running the application I am getting the following error. Can anyone please help me with this. Thanks in advance.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/parse/AbstractQueryController$1.class
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.tanmaykulkarni.appname"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.parse.bolts:bolts-android:1.3.0'
compile 'com.parse:parse-android:1.12.0'
compile 'com.parse:parsefacebookutils-v4-android:1.10.4#aar'
}
You should search for AbstractQueryController to check which dependency this class includes. Then you should update you script to ensure that this class is only included once. Do it like in the following example:
testCompile('org.robolectric:robolectric:3.0') {
//exclusions due to android.jar conflict
exclude module: 'httpclient'
exclude module: 'commons-logging'
}

Categories