Error ':app:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: - android

I am developing android application for Home Automation using gradle in Android Studio. There is no problem when I build the project, but when I try to run the project, there is an error like this:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: org/apache/http/params/CoreConnectionPNames.class
Here is my build.gradle codes:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.cpl"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:23.0.1'
compile files('libs/android.jar')
compile files('libs/bcprov-jdk15on-1.47.jar')
//compile files('libs/google-play-services.jar')
//compile files('libs/google-play-services1.jar')
compile files('libs/httpclient-4.2.3.jar')
compile files('libs/httpcore-4.3.jar')
compile files('libs/nineoldandroids-library-2.4.0.jar')
compile files('libs/Pubnub-Android-3.7.2.jar')
compile files('libs/renderscript-v8.jar')
compile files('libs/sun.misc.BASE64Decoder.jar')
compile files('libs/universal-image-loader-1.9.2.jar')
//compile files('libs/android-support-multidex.jar')
compile 'com.android.support:multidex:1.0.1'
}
please help me to solve this problem. Thank you anyway

Please change your gradle dependencies as following :
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:23.0.1'
compile files('libs/renderscript-v8.jar')
compile files('libs/sun.misc.BASE64Decoder.jar')
compile 'org.apache.httpcomponents:httpclient:4.2.3'
compile 'org.bouncycastle:bcprov-jdk15on:1.47'
compile 'org.apache.httpcomponents:httpcore:4.3'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.pubnub:pubnub-android:3.7.2'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
compile 'com.android.support:multidex:1.0.1'
Note :
In Gradle when we do not use gradle dependency and if our libs folder dependencies contains duplicate class then
java.util.zip.ZipException: duplicate entry
This exception occurs.
So Whenever you add dependencies then if possible then try maximum to use maven dependencies.
Thank you.!!

Try adding following dependencies:
compile 'com.google.android.gms:play-services-plus:8.1.0'
compile 'com.google.android.gms:play-services-location:8.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-maps:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'

Related

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > error

Please help me to find a solution on this error.. When I build my project I got an error like this
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbq.class
Please check ones my build.gradle(App level) file... Please give me a hint to move farword
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.realmilk.app.new"
minSdkVersion 15
targetSdkVersion 25
versionCode 6
versionName "1.0.6"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':volley')
compile project(':materialviewpager')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'io.github.yavski:fab-speed-dial:1.0.3'
compile 'com.wdullaer:materialdatetimepicker:2.2.0'
compile 'com.jaredrummler:material-spinner:1.0.5'
compile 'it.neokree:MaterialTabs:0.11'
compile 'com.github.siyamed:android-shape-imageview:0.9.+#aar'
compile 'me.tatarka.support:jobscheduler:0.1.1'
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha2'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
testCompile 'junit:junit:4.12'
}
Please give me your valuable suggestions... Thanks
You are using 2 different versions of play service.
Change
compile 'com.google.android.gms:play-services-analytics:8.1.0'
to
compile 'com.google.android.gms:play-services-analytics:9.2.1'
So that both the auth and analytics service have same versions.
Similar question.
https://stackoverflow.com/a/38201741/3111083.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/MessageConstraintException.class

I migrate my Android eclipse project to Android Studio project, but when I try to run my app it flags the following error--
Error:Execution failed for task ':wikiNews:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/MessageConstraintException.class
For more information below is my build.gradle file--
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "com.abc.wikiNews"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':easyAndroidAnimationsLibrary')
compile project(':liveSdk')
compile project(':main')
compile project(':zbarSample')
compile project(':stickyHeaderLibrary')
compile project(':starBar')
compile project(':facebookSDK')
compile project(':library')
compile project(':ffmpeg4android_lib')
compile project(':socialNetworkingLib')
/*compile 'com.google.android.gms:play-services:+'*/
compile 'com.google.android.gms:play-services:9.6.1'
/*compile 'com.android.support:appcompat-v7:23.4.0'*/
/* compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'*/
compile files('libs/nmdp_speech_kit.jar')
compile files('libs/AndroidSwipeLayout-v1.1.8.jar')
compile files('libs/commons-logging-1.2.jar')
compile files('libs/CWAC-SackOfViewsAdapter.jar')
compile files('libs/devsmartandroid.jar')
compile files('libs/google-api-client-1.6.0-beta.jar')
compile files('libs/google-api-services-plus-v1-1.3.0-beta.jar')
// compile files('libs/google-oauth-client-1.6.0-beta.jar')
compile files('libs/httpclient-4.4.jar')
compile files('libs/httpcore-4.4.jar')
// compile files('libs/thttpmime-4.3.5.jar')
compile files('libs/picasso-2.4.0.jar')
compile files('libs/signpost-commonshttp4-1.2.1.2.jar')
compile files('libs/signpost-core-1.2.1.2.jar')
compile files('libs/signpost-jetty6-1.2.1.2.jar')
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3')
{
exclude module: "httpclient"
}
}
Also please let me know if I can provide more information. Thank you.
Remove these dependencies in your gradle file :
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
And dd this dependency in your gradle file :
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'

TransformException after migrating to Android Studio

I tried to import a working Eclipse Android project to Android Studio. I am working on Mac with the latest version of Android Studio. When I try to build, it keeps on displaying this error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
com/google/api/client/http/AbstractHttpContent.class
The class generating this issue is in the com.google.http-client:google-http-client-gson:1.20.0 library, in the com.google.api.client.http package. I tried many things with the app.gradle file, such as excluding the com.google.api.client.http group but nothing works. Here is my app.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.time2"
minSdkVersion 17
targetSdkVersion 19
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions.encoding = 'ISO-8859-1'
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.1'
compile files('libs/commons-io-2.4.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-http-client-1.18.0-rc.jar')
compile files('libs/google-http-client-android-1.18.0-rc.jar')
compile files('libs/google-oauth-client-1.18.0-rc.jar')
compile files('libs/httpcore-4.3.3.jar')
compile files('libs/httpmime-4.3.6.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
compile 'com.stripe:stripe-android:+'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}
You should avoid manually adding in libs to your project.
E.g. change
compile files('libs/commons-io-2.4.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-http-client-1.18.0-rc.jar')
compile files('libs/google-http-client-android-1.18.0-rc.jar')
compile files('libs/google-oauth-client-1.18.0-rc.jar')
compile files('libs/httpcore-4.3.3.jar')
compile files('libs/httpmime-4.3.6.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
to
compile 'commons-io:commons-io:2.4'
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.http-client:google-http-client:1.18.0-rc'
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client:1.18.0-rc'
compile 'org.apache.httpcomponents:httpcore:4.3.3'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.google.code.findbugs:jsr305:1.3.9'
Please verify that these are the correct packages. Let us know what you find after updating?
The library 'com.google.http-client:google-http-client-gson:1.20.0' is composed of the following nine modules:
google-http-client
google-http-client-android
google-http-client-appengine
google-http-client-xml
google-http-client-protobuf
google-http-client-jdo
google-http-client-jackson
google-http-client-jackson2
google-http-client-gson
Some of these e.g. google-http-client is included again in tour dependencies as a jar. Hence the duplicate entry.
Check this link for getting the setup right when using google-http-java-client. It has step by step instruction - Setup Instructions

Error:Execution failed for task ':packageAllDebugClassesForMultiDex'

I'm trying to implement youtube search in my application. I have got the following error
Error:Execution failed for task ':packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/common/annotations/Beta.class
Here is my gradle file
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'org.lucasr.twowayview:twowayview:0.1.4'
compile 'com.google.guava:guava:18.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.google.apis:google-api-services-youtube:v3-rev145-1.20.0'
compile 'com.google.oauth-client:google-oauth-client-jetty:1.20.0'
compile project(':qsmack322')
compile project(':viewpagerindicator')
compile project(':Emojicon')
compile project(':CircleLoader')
compile files('libs/acra-4.5.0.jar')
compile files('libs/android-sqlite-asset-helper.jar')
compile files('libs/aws-android-sdk-2.1.7-core.jar')
compile files('libs/aws-android-sdk-2.1.7-s3.jar')
compile files('libs/commons-io-2.4.jar')
compile files('libs/daocore.jar')
compile files('libs/gcmnoti.jar')
compile files('libs/google-api-client-1.4.1-beta.jar')
compile files('libs/google-api-client-googleapis-1.4.1-beta.jar')
compile files('libs/httpmime-4.1.1.jar')
compile files('libs/jackson-core-asl-1.6.7.jar')
compile files('libs/newrelic.android.jar')
compile files('libs/rebound-v0.3.3.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
compile files('libs/universal-image-loader-1.9.1-with-sources.jar')
}
Pls help me!!!
duplicate entry, this may mean
compile files('libs/google-api-client-1.4.1-beta.jar')
compile files('libs/google-api-client-googleapis-1.4.1-beta.jar')
remove one of them ..
Try to add multiDexEnabled true in your gradle
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.your.package"
minSdkVersion 17
targetSdkVersion 22
multiDexEnabled true
}
}

duplicate entry: com/google/android/gms/common/SupportErrorDialogFragment.class

I am creating project in android studio with multi dex support . I am getting error : java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/SupportErrorDialogFragment.class . I know this issue is for duplicate class. But unable to figure out that which class is getting duplicate and how to fix it. Below are the code of my build.gradle. Please suggest. Thanks.
android {
compileSdkVersion 19
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.rtpl.create.app.v2"
minSdkVersion 14
targetSdkVersion 19
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':pageIndicator')
compile project(':materialDesign')
compile project(':zxingLib')
compile project(':datetimepickerlibrary')
compile project(':facebookSDK')
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/Android_SDK.jar')
compile files('libs/Android_SDK_component.jar')
compile files('libs/crashlytics.jar')
compile files('libs/google-play-services.jar')
compile files('libs/im.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/linkedin-j-android.jar')
compile files('libs/PayPal_MECL.jar')
compile files('libs/prime-0.6.1.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/signpost-jetty6-1.2.1.1.jar')
compile files('libs/socialauth-4.2.jar')
compile files('libs/socialauth-android-2.6.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
compile files('libs/universal-image-loader-1.9.1-SNAPSHOT-with-sources.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile files('libs/gcm.jar')
compile 'com.android.support:multidex:1.0.0'
}
You have conflicting dependencies in your build.gradle, meaning multiple dependencies containing the same classes:
compile 'com.google.android.gms:play-services:+'
compile files('libs/google-play-services.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/gcm.jar')
All of these components are provided by Google Play Services (the first one in the list). So you should only declare Google Play Services once, preferably only the components you're using instead of the full package: See "Selectively compiling APIs into your executable" https://developers.google.com/android/guides/setup
Chances are you won't even need multidex after you simplify your project dependencies.
Also (unrelated), I'm wondering what are these dependencies, if it's the Android framework itself you can remove them:
compile files('libs/Android_SDK.jar')
compile files('libs/Android_SDK_component.jar')

Categories

Resources