Android Studio: duplicate entry: android/support/annotation/DrawableRes.class - java

Kindly need your expertise. This error came up when I add compile 'com.android.support:design:23.2.1' in my gradle.
Error:Execution failed for task
':myApp:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
android/support/annotation/DrawableRes.class
Here is my gradle dependencies file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.iws.iwsapp"
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':facebookSDK')
compile project(':library')
compile 'com.android.support:appcompat-v7:23.2.1'
compile files('libs/android-query-full.0.26.7.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile files('libs/mint-5.0.0.jar')
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile files('libs/android-support-v13.jar')
compile 'com.android.support:design:23.2.1'
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
Appreciate the help. Thank you.

It seems that you have duplicate support/annotation/DrawableRes.class. Make sure all your lib project:
facebookSDK
library
and all jar libraries under libs directory didn't include the android.support.anotation package.
If you are sure you didn't use annotation package, you can exclude annotation in your app build.gradle file like this.
android{
...
configurations {
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
}

Related

I'm getting an error when building my APK

I'm getting this error when I try to build my APK. I'm currently mantaining and buf-fixing this app from another developer. In the gradle he used .+ in every compile. How can I fix it?
The Error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/design/widget/CoordinatorLayout.class
The gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.easyfixapp.easyfix"
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy {
force 'com.google.code.findbugs:jsr305:3.0.1'
}
}
}
realm {
syncEnabled = true;
}
repositories {
mavenCentral()
}
dependencies {
compile('com.facebook.android:facebook-android-sdk:[4,5)') {
exclude group: 'com.android.support', module: 'multidex'
}
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.theartofdev.edmodo:android-image-cropper:2.6.+'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:support-v4:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:support-vector-drawable:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:mediarouter-v7:26.+'
compile 'com.google.android.gms:play-services:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'com.hbb20:ccp:2.0.5'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
compile 'com.github.bumptech.glide:glide:4.2.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.chrisbanes:PhotoView:2.0.0'
compile('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true;
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Remove all of the "+" in your libraries dependency's
version
Try this in your app level gradle file
implementation('com.github.bumptech.glide:glide:4.6.1') {
exclude group: 'com.android.support'
}`
if it does not solve try logging dependencies run this command
./gradlew -q dependencies app:dependencies --configuration compile
in your android studio's Terminal Tab it will log all the dependency tree of your project
then find which libraries are using duplicating dependencies
for example
implementation 'com.github.bumptech.glide:glide:4.6.1'
is using duplicate dependencies so change
implementation 'com.github.bumptech.glide:glide:4.6.1'
to
implementation('com.github.bumptech.glide:glide:4.6.1') {
exclude group: 'com.android.support'
}

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 :)

Unable to Merge Dex Android Studio 3.0 after update

updated my project to gradle 3 and generated this error
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
in another questions says "libraries having transitive dependency " but i don't find the library with this transitive dependency
in gradle 2.3 don't show this error
build.gradle app
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
compileOptions.encoding = 'UTF-8'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.my.my"
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jni.srcDirs = ["libs"]
}
}
packagingOptions {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':dd-plist')
compile project(':Emojicon')
compile project(':CameraModule')
compile project(':ScapeUtils')
compile project(':circleimageview')
compile project(':FFMPG')
compile project(':PdfViewer')
compile project(':LibLinphone')
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.ornolfr:rating-view:0.1.1#aar'
compile 'cat.ereza:customactivityoncrash:1.5.0'
compile 'com.writingminds:FFmpegAndroid:0.3.2'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile "com.android.support:appcompat-v7:26.1.0"
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'org.apache.commons:commons-io:1.3.2'
}
apply plugin: 'com.google.gms.google-services'
build.gradle project
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
}
I am battling also with this or similar problem. I have set to use the old gradle version manually. From File/Project structure/projet I have put gradle version 3.4.1 and plugin version 2.3.3
I have also added multiDexEnabled true in app/build.gradle inside defaultConfig Hth

Build failed: "java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command.class"

I'm trying to port an old android app to new devices. It works well from Android 5.x to 7.1, but it doesn't work in Android 4.x versions.
When I try to install it in an android device or in a emulator with Android 4.x the build always fails with the same exception:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command.class
I tried to search that "duplicate entry", but I was unable. I'm not sure what's the problem.
This is my build-gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "app-name"
minSdkVersion 14
targetSdkVersion 17
multiDexEnabled true
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile ('com.android.support:support-v4:25.0.0'){
exclude module: 'support-v4'
}
compile ('com.google.android.gms:play-services:8.4.0'){
exclude module: 'support-v4'
}
compile files('libs/libGoogleAnalyticsServices.jar')
}
Remove the line:
compile ('com.google.android.gms:play-services:8.4.0'){
exclude module: 'support-v4'
}
or
compile files('libs/libGoogleAnalyticsServices.jar').
you are compiling same library two time as
'com.google.android.gms:play-services:8.4.0'
also have GoogleAnalyticsServices module.

Duplicated files copied in APK. Android

I'm trying to send a file to my Datastore of google. When I try to run the application I take the following error:
Error:Execution failed for task
':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files
copied in APK
com/google/appengine/repackaged/org/apache/commons/codec/language/bm/sep_approx_spanish.txt
File1:
C:\Users\Javier.gradle\caches\modules-2\files-2.1\com.google.appengine\appengine-endpoints\1.9.28\bf2e8a74bd28e388b3487fc78a0c7adfa592fd5d\appengine-endpoints-1.9.28.jar
File2:
C:\Users\Javier.gradle\caches\modules-2\files-2.1\com.google.appengine\appengine-api-1.0-sdk\1.9.34\7c15c22fd362478e9758081d28e51590304d5ff4\appengine-api-1.0-sdk-1.9.34.jar
I tried exclude the file with
packagingOptions {
exclude 'sep_approx_spanish.txt'
}
but it doesn't work. My Build.gradle is the next:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.javier.wh"
minSdkVersion 23
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'sep_approx_spanish.txt'
}
}
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.0.1'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.android.support:support-v4:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.google.code.findbugs:jsr305:2.0.1'
testCompile 'junit:junit:4.12'
compile project(path: ':backend', configuration: 'android-endpoints')
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.34'
compile 'com.google.appengine:appengine-endpoints:1.9.28'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.28'
compile 'javax.servlet:servlet-api:2.5'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.guava:guava:19.0'
compile 'com.googlecode.objectify:objectify:5.1.12'
}
Someone had the same problem?
Help please!
Put below line in your app build.gradle inside android block
packagingOptions {
pickFirst 'com/google/appengine/repackaged/org/apache/commons/codec/language/bm/sep_approx_spanish.txt'
}

Categories