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

here's my build.gradle dependencies part :
`
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile files('libs/google-play-services.jar')
compile files('libs/android-async-http-1.4.9.jar')
compile 'cz.msebera.android:httpclient:4.3.6'
compile 'com.google.android.gms:play-services-location:7.+'
and my error is :
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/UserRecoverableAuthException.class
what's the cause of the error ??

You are adding google-play-services twice in your gradle file.
compile files('libs/google-play-services.jar')
compile 'com.google.android.gms:play-services-location:7.+'
Remove the following line from your build.gradle file.
compile files('libs/google-play-services.jar')

you need use multidex in project link

Related

How to fix Failed to resolve: support-core-utils?

In my application i added some dependencies into buld.gradle file and when click on sync button show me below error :
Failed to resolve: support-core-utils
Open File
My build.gradle :
dependencies {
implementation 'com.android.support:support-v4:27.1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:cardview-v7:27.1.0'
//Retrofit, gson
compile 'com.squareup.retrofit2:converter-scalars:2.1.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
//
compile('ir.approo:helper:0.4.7-SNAPSHOT')
compile('ir.approo:core:0.4.7-SNAPSHOT')
}
When added this lines show me error :
compile('ir.approo:helper:0.4.7-SNAPSHOT')
compile('ir.approo:core:0.4.7-SNAPSHOT')
I added below dependency into build.gradle and click on sync but again show me above error :
compile 'com.android.support:support-core-utils:27.1.0'
How can i fix it?

I donĀ“t understand: Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'

I don't understand this error:
Error:
Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$PrintHelperStubImpl.class
Code:
dependencies {
compile ('com.google.android.gms:play-services:+'){exclude module: 'support-v4'}
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
compile ('com.android.support:multidex:1.0.1'){exclude module: 'support-v4'}
}
Thanks in advance
Try removing the line compile files('libs/support-v4-19.0.1.jar') (and probably {exclude module: 'support-v4'}). It is probably the android/support/v4 library, which is already inside the default classpath when compiling android projects.

Gradle compile error with same module

i am trying to import 2 Libraries with Gradle.
When i am importing one of them its working but when i compile both i get the exception below.
I am working with Android Studio.
Getting the exception below:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/bouncycastle/crypto/CipherParameters.class
and my dependencies:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile ('org.bouncycastle:bcprov-jdk15on:1.50') {
exclude module: 'bcpkix-jdk15on' // Excluded to prevent cyclic dependencies
}
compile ('org.bouncycastle:bcpkix-jdk15on:1.50') {
exclude module: 'bcprov-jdk15on' // Excluded to prevent cyclic dependencies
}
}
Thanks
Marvin
Android is already using a cut down version of bouncy castle. It worked with com.madgag.spongycastle.

duplicate entry: com/google/android/gms/measurement/AppMeasurementContentProvider.class

This error started appearing after I updated firebase SDK on my project. If i try to build the project normally its working fine. but whenever trying to build a signed APK its giving the following error.
Error:Execution failed for task
':app:transformClassesWithJarMergingForProductionRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
com/google/android/gms/measurement/AppMeasurementContentProvider.class
here are my project dependencies. not sure where the duplication is occurring.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile(name: 'google-maps-sdk-m4b', ext: 'aar')
compile('io.intercom.android:intercom-sdk:1.+#aar') { transitive = true }
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.google.code.gson:gson:2.4'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.mixpanel.android:mixpanel-android:4.6.4'
compile 'com.google.maps.android:android-maps-utils:0.4.1'
compile 'com.stripe:stripe-android:+'
compile 'com.github.jkwiecien:EasyImage:1.2.1'
compile 'com.github.dbachelder:CreditCardEntry:1.4.7'
compile 'com.appsflyer:af-android-sdk:4.3.5#aar'
compile 'com.bugsnag:bugsnag-android:+'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.google.android.gms:play-services-location:9.0.2'
compile 'com.google.firebase:firebase-database:9.0.2'
compile 'com.google.firebase:firebase-auth:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'cn.aigestudio.wheelpicker:WheelPicker:1.1.0'
}
apply plugin: 'com.google.gms.google-services'
I have solved by changing
classpath 'com.google.gms:google-services:2.0.0-alpha2'
To
classpath 'com.google.gms:google-services:3.0.0'
In project level gradle file
So I figured solution to the problem. Adding exclude group: 'com.google.android.gms' solved the issue:
compile('io.intercom.android:intercom-sdk:1.+#aar') {
transitive = true
exclude group: 'com.google.android.gms'
}

Jar merging for debug throwing duplicate entry with android?

Im getting this error when trying to run my build:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/AnimatorRes.class
Here is my build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile('com.digits.sdk.android:digits:1.9.0#aar') {
transitive = true;
}
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'me.zhanghai.android.materialprogressbar:library:1.0.2'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.anjlab.android.iab.v3:library:1.0.+#aar'
}
Here is a pic of my libs
Im hoping someone here can help me find out what the issue is. Im using android studio.
Try excluding the support-v4 since the google-play-services already contains the support-v4
compile ('com.google.android.gms:play-services:8.1.0')
{
exclude group: 'com.android.support', module: 'support-v4'
}
if it doesn't work,
Clean the project and rebuild it.
Else, try setting multiDexEnabled in the gradle file
defaultConfig {
multiDexEnabled true
}

Categories