I'm facing a strange problem : When I compile my app to run it on a device with android 7.0 it works but when I am trying to compile for a device with android 4.2.1 it fails with that error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/squareup/okhttp/Address.class
I don't understand why, I think it is cause by a problem of the build gradle file. Here is my gradle file:
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda' // make sure to apply last!
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.qsmart.illicity"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
applicationVariants.all { variant ->
variant.resValue "string", "versionName", variant.versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
preDexLibraries = false
}
}
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.android.support:appcompat-v7:25.2.0'
compile "com.android.support:support-v4:25.2.0"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.jakewharton:butterknife:8.5.1'
compile('org.apache.commons:commons-io:1.3.2'){
exclude module: 'commons-io'
}
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'com.github.lsjwzh.RecyclerViewPager:lib:v1.1.2#aar'
/*For Slider*/
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
/*End For Slider*/
/*gauge*/
compile 'pl.pawelkleczkowski.customgauge:CustomGauge:1.0.3'
/*end of gauge*/
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
testCompile 'junit:junit:4.12'
}
If someone have an idea ... Because I tried a lot of thinks like exclude okhttp from configuration etc but nothing have work.
SOLUTION
I have change
//compile 'com.squareup.okhttp:okhttp:2.4.0'
//compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
by
compile 'com.squareup.okhttp3:okhttp:3.8.1'
and change version of picasso to 2.5.2
and finally added:
configurations{
all*.exclude module: 'okhttp'
all*.exclude module: 'okio'
}
You should use okhttp3:okhttp:n.n1.n2
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.squareup.picasso:picasso:2.5.2'
If you receive duplicate entry: okio/AsyncTimeout$1.class Then add below
android {
configurations{
all*.exclude module: 'okhttp'
all*.exclude module: 'okio'
}
}
Try to use only one dependency.
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
Related
I am making an app in which can edit photos and videos.It also shares edited photos via timeline which is made using Recycler view and Card view.
I am having an error whenever I try to run my app in Android SDK 22 but it is working file in Android SDK 23 and above.
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/iid/zzc.class
It occurs also I am building apk.
Gradle File for my app
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.practice.android.moments"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [appPackageName: "${applicationId}"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
/* 3)(Creative SDK) Exclude duplicate licenses */
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
//help
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
pickFirst 'AndroidManifest.xml'
}
}
repositories {
mavenCentral()
}
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:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-storage:11.0.1'
compile 'com.google.firebase:firebase-ads:11.0.1'
compile 'com.google.firebase:firebase-invites:11.0.1'
compile 'com.google.firebase:firebase-appindexing:11.0.1'
compile 'com.google.firebase:firebase-crash:11.0.1'
compile ('com.facebook.android:audience-network-sdk:4.11.0'){
exclude group: 'com.google.android.gms'
}
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.adobe.creativesdk.foundation:auth:0.9.1251'
compile 'com.adobe.creativesdk:image:4.8.4'
compile 'com.localytics.android:library:3.8.0'
testCompile 'junit:junit:4.12'}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'}
apply plugin: 'com.google.gms.google-services'
Can any one please help me...
Phone used for testing
Meizu M2 Note OS version 5.1 Lollipop API 22
Redmi Note 3 OS version 6.0.1 Marshmallow API 23
Samsung Note 5 OS version 7.0 Nougat API 24
In my case,this error occurs because I have two different version of google-play-service lib.
I remove one of them,bingo!
Try move this compile
compile 'com.google.android.gms:play-services-auth:11.0.1'
im working with android,
When the gradle syncs works good, but if I try to compile show me 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/zzak.class
Follow the another answers in here and here ,
if I delete google play services, result its same.
But the result its same, my gradle:
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.procibernetica.moca"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
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:multidex:1.0.1'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-gcm:9.6.1'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.android.gms:play-services-auth:9.6.1'
compile 'com.google.gms:google-services:3.0.0'
compile 'com.google.firebase:firebase-database:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-auth:9.6.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.github.satyan:sugar:1.5'
compile 'com.android.support:design:25.3.1'
compile 'org.msgpack:msgpack:0.6.11'
compile 'com.theneura:android-sdk:+'
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.2#aar') {
transitive = true
}
compile project(':moca-sdk-android-1.9.6')
testCompile 'junit:junit:4.12'
}
Follow the tutorial:
https://developers.google.com/android/guides/setup
I remove:
compile 'com.google.android.gms:play-services-gcm:9.6.1'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.android.gms:play-services-auth:9.6.1'
And change for:
compile 'com.google.android.gms:play-services:10.2.4'
And works
I can run my application on devices using USB, But when i tried to build APK it's measure this error :
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/HttpHeaders.class
my gradle :
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "elryad.harajsooq"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
buildTypes {
release {
minifyEnabled 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 group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.2.3'
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5'
// compile 'org.apache.httpcomponents:httpcore:4.4.1'
// compile 'org.apache.httpcomponents:httpclient:4.5'
// compile 'org.apache.httpcomponents:httpmime:4.2.3'
compile files('libs/volley.jar')
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.support:support-annotations:25.3.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:palette-v7:25.3.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.android.support:cardview-v7:25.3.0'
compile 'com.squareup.okhttp3:okhttp:3.1.2'
//compile 'com.android.support:support-v7:25.0.2'
compile "com.android.support:support-core-utils:25.3.0"
compile 'com.android.support:support-v13:25.3.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
}
Legacy Apache HTTP
You're bundling a version of Apache HTTP with your app. Remove this line from all modules' build.gradle:
useLibrary 'org.apache.http.legacy'
Behind the scenes that method actually includes a JAR of an old version of Apache HTTP which is not what you want if you're managing dependencies through Gradle/maven.
Matching versions
All imported artifacts from Apache HTTP have to have the same version.
compile 'org.apache.httpcomponents:httpmime:4.5.3'
compile 'org.apache.httpcomponents:httpclient-android:4.5.3'
Well, httpcore does not follow this sheme, then again consider it an internal transitive dependency, appropriate version is pulled automatically by whatever version of httpclient you use. You don't have to specify it manually.
List of Apache HTTP artifacts in maven: https://mvnrepository.com/artifact/org.apache.httpcomponents
I have this problem when i will to compile my project:
And when i will build my project to APK i have this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/objectweb/asm/tree/AbstractInsnNode.class
This is my gradle.
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "come.texi.driver"
minSdkVersion 16
targetSdkVersion 23
versionCode 2
versionName "2.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// compile 'com.jakewharton:butterknife:7.0.1'
//compile 'com.loopj.android:android-async-http:1.4.9'
compile project(':facebooklibrary')
compile project(':slideMenuLibrary')
compile project(':stripe')
compile('com.twitter.sdk.android:twitter:1.13.0#aar') {
transitive = true
}
//compile 'com.github.nkzawa:socket.io-client:0.3.0'
compile('io.socket:socket.io-client:0.7.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
//compile 'com.paypal.sdk:paypal-android-sdk:2.14.4'
compile('com.paypal.sdk:paypal-android-sdk:2.14.4') {
exclude group: 'org.json', module: 'json'
}
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'cz.msebera.android:httpclient:4.4.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.victor:lib:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.tools.build:gradle:2.2.3'
testCompile 'junit:junit:4.12'
}
Help me!!
I had the exact same problem, except I am using Android Gradle Plugin 2.3.3, but that's not the issue. Here is how I solved it, hope this will help you.
Inside android, add the packagingOptions to exclude AUTHORS like this:
android {
packagingOptions {
exclude 'AUTHORS'
}
}
Here is some documentation reference
I am getting this error
Error:Execution failed for task ':yourapp:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v7/recyclerview/BuildConfig.class
Here is my build.gradle file
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.test"
minSdkVersion 15
multiDexEnabled true
targetSdkVersion 22
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile (project(':library_slidingmenu')) {
exclude group: 'com.android.support', module: 'recyclerview-v7'
}
compile project(':library')
compile 'com.android.support:appcompat-v7:22.2.1'
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
compile 'org.projectlombok:lombok:1.16.6'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:cardview-v7:22.1.0'
compile 'com.android.support:recyclerview-v7:22.1.0'
Any idea how to solve it?
If you have a dependency that also declares the recyclerview lib then just exclude it from the dependency. For example imagine your lib library_slidingmenu contains the recyclerview dependency, then we would need to do something like this
dependencies {
compile project(':library_slidingmenu') {
exclude group: 'com.android.support', module: 'recyclerview-v7'
}
// the rest of your dependecies
}