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
}
Related
My build.gradle
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 30
buildToolsVersion '30.0.2'
defaultConfig {
applicationId "com.rock08.android.demoapp"
minSdkVersion 22
targetSdkVersion 25
versionCode 2
versionName "0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
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'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:leanback-v17:25.4.0'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.android.support:preference-v7:25.4.0'
compile 'com.android.support:preference-v14:25.4.0'
compile 'com.android.support:preference-leanback-v17:25.4.0'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:palette-v7:25.4.0'
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
The gradle build is getting failed.
ERROR- Could not find method compile() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
This is expected with Gradle 7.2 since the compile and testCompile configurations have been removed.
You must replace compile with implementation and testCompile with testImplementation
My solution is.
jar file Directory is /WEB-INF/lib/MyJarFile.jar :)
flatDir {
name 'lib'
dirs "$rootProject.projectDir/lib"
}
dependencies {
classpath fileTree(dir: 'lib', include: 'MyJarFile.jar')
}
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'
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'
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 was trying to compile the app but these errors showed up what should I do?
Error:Failed to resolve: com.android.support:cardview-v7:23.4.0
Error:Failed to resolve: com.android.support:support-v4:23.4.0
Error:Failed to resolve: com.android.support:customtabs:23.4.0
The source code is
apply plugin: 'com.android.application'
android
{
signingConfigs {}
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig
{
applicationId "com.boonex.oo"
minSdkVersion 15
targetSdkVersion 21
}
buildTypes
{
release
{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories
{
jcenter()
}
dependencies
{
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.android.support:support-v4:23.1.1'
}
Try an earlier more specific version of the Facebook SDK.
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
bro.. just look at that.. your compileSdkVersion is 21. so you are not able to use higher version of appCompat gradle. for that first you have to update your sdk to 23.
you can see my gradle and it should be like that:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.apple"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile project(':library')
compile files('libs/httpmime-4.3.jar')
compile files('libs/gcm.jar')
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:multidex:1.0.1'
compile 'com.firebase:firebase-client-android:2.3.1'
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpclient-4.3.3.jar')
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-vector-drawable'
all*.exclude group: 'com.android.support', module: 'animated-vector-drawable'
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
you can see that my compileSdkVesion is 23 so my each com.android.support gradle is 23.
sorry to mention lately.. you also need to change class-path for avoid compatibility issue of latest version.
classpath 'com.android.tools.build:gradle:2.1.2'
and this all thing is only possible when you upgrade your sdk first.