java.util.zip.ZipException: duplicate entry: dagger/Provides.class - android

When I sync the project everything is ok, but when I try to run I've got this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: dagger/Provides.class
Here is my app build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "appID"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
apt 'com.google.dagger:dagger-compiler:2.5'
compile 'com.google.dagger:dagger:2.5'
provided 'javax.annotation:jsr250-api:1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile('com.sumup:merchant-sdk:1.61.0#aar') {
transitive = true
}
}
If I run without compile 'com.google.dagger:dagger:2.5' it is success compiled.. please help.

UPDATE:
It looks like sumup sdk is not compatible with dagger 2.+.
So I have downgrade to dagger 1.+ and it is working ok. No other issues appeared until now.

Before downgrading, would you consider trying replacing compile 'com.google.dagger:dagger:2.5' with the following:
compile ('com.google.dagger:dagger:2.0') {
exclude group: 'javax.inject'
}
This will exclude the duplicate class.

I had the similar issue when we switched to Dagger.
We use same package names in different artifacts for the #Component and #Module classes and the Dagger generated the same Dagger...Component.java file in every artifact where we use the same package.
After we moved the components into unique packages in every artifacts, the problem was solved with it.

Related

Android Studio APK build error - Multiple dex files define Landroid/support/v4/

//Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.cpsraozan.admission"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
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 'com.android.support:appcompat-v7:27.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
}
apply plugin: 'com.google.gms.google-services'
Go to your build.gradle file and add multidexEnable true on defaultConfig.
android {
compileSdkVersion 26
defaultConfig {
targetSdkVersion ..
multiDexEnabled true //add this
}
}
For more information See this
This is kind of NOT straight forward. Most likely you might have added a new dependency or updated a dependency which is causing multiple versions of the same library being added as a dependency.
Check if Android studio is highlighting any lines for this, especially in Gradle files.
Run a dump of all dependencies Gradle is processing using the command
./gradlew -q dependencies app:dependencies
check for conflicting dependencies and fix them.
I was struggling this morning with the same error and the requirement for multiDexEnabled didn't make sense. This is only for large projects with more than 64k methods. I found this solution somewhere on SO, but couldn't find it again. So reposting the answer.

BUILD FAILED , Information:Gradle tasks [:app:assembleLegacyRelease]

thanks for your time :)
i'm getting this message after building my game on android studio
Information:Gradle tasks [:app:assembleLegacyRelease]
Error:Execution failed for task ':app:transformClassesWithJarMergingForLegacyRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/ListFragment$1.class
Information:BUILD FAILED
i've used a legacy release so i don't know how to solve this problem to get my apk file
this is the gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
dexOptions{
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 9
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
legacy {
minSdkVersion 9
versionCode 901 // Min API level 9, v01
}
current {
minSdkVersion 14
versionCode 1401 // Min API level 14, v01
}
}
dependencies {
legacyCompile 'com.google.android.gms:play-services:10.0.0'
currentCompile 'com.google.android.gms:play-services:10.2.0'
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.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:support-vector-drawable:25.0.0'
testCompile 'junit:junit:4.12'
}
sourceSets {
main {
jni.srcDirs = []
}
}
}
thank you for your help , this is my first game
So you've four jar files in your libs folder already which includes support v4 jar as well. Here are the jar files you have in your libs folder as far as I know from your comment.
dagger 1.2.2.jar
javax.inject -1.jar
nineoldandroids-2.4.0.jar
support v4-19.0.1.jar
The error message clearly shows that there's duplicate entry for a support v4 jar.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/ListFragment$1.class
So you need to remove the support v4-19.0.1.jar from your libs folder as you already have a support v7 included in your build.gradle file which has a different version. So you might consider adding this section in your build.gradle file just before your dependencies section.
configurations.all {
resolutionStrategy {
force 'com.android.support:design:25.3.1'
force 'com.android.support:support-v4:25.3.1'
force 'com.android.support:appcompat-v7:25.3.1'
}
}
You might also consider removing compile 'com.android.support:appcompat-v7:25.0.0' from your dependencies as well.
You are having ListFragment class in your project, that is conflicting with ListFragment class provided by Android Fragments pre-defined class. Please refractor your own ListFragment class. That should solve the error.

Build Failed 'duplicate entry: com/google/api/client/googleapis/auth/clientlogin/ClientLogin$Response.class

Error description:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/api/client/googleapis/auth/clientlogin/ClientLogin$Response.class
build.gradle code here
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion '23.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.jasp.eventapp"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.8.2'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.couchbase.lite:couchbase-lite-android:1.4-46'
//compile 'com.google.api-client:google-api-client-android:1.22.0'
//compile 'com.google.api-client:google-api-client-xml:1.22.0'
compile 'com.google.api.client:google-api-client:1.4.1-beta'
compile 'com.google.api-client:google-api-client-jackson2:1.22.0'
compile files('libs/google-api-client-1.5.0-beta.jar')
compile 'com.google.android.gms:play-services:9.2.1'
}
Any version problem in imported libs...?How can I handle this...?I tried by cleaning the project
Build - > Clean
after that rebuild, But no effect...Can any one please help me...
This error occurs when you are using duplicate version of same library, or when you use a library project which has same dependency
compile 'com.google.api.client:google-api-client:1.4.1-beta'
compile 'com.google.api-client:google-api-client-jackson2:1.22.0'
compile files('libs/google-api-client-1.5.0-beta.jar')
these three looks like same library , removing duplicate version of the library should fix your error
I had the same problem with Feign library. Look in the .idea\libraries directory in your project, find the same library with different versions and remove one. It should be help.

Gradle Build Run error (DebugUtils.class) in Android Studio 1.5

I'm getting the following error
Error:Execution failed for task
:app:transformClassesWithJarMergingForDebug.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/util/DebugUtils.class
I searched the entire day but couldn't found a proper answer which will solve my problem.
My app bulid gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.project.test"
multiDexEnabled true
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
// depend files
dependencies
{
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-ads:+'
compile 'com.google.android.gms:play-services-identity:+'
compile 'com.google.android.gms:play-services-gcm:+'
compile files('libs/android-support-v4.jar')
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
}
I tried Clean and Rebuild, but that also not working.
Please help on this. Thanks in advance.
This issue happens when you add the same class twice.
In your project you are adding many times the support-v4 library.
remove android-support-v4.jar from libs folder
remove this line compile files('libs/android-support-v4.jar')
change the dependency of the library 'com.github.JakeWharton:ViewPagerIndicator:2.4.1' because it uses an old support-v4.jar
Use:
compile ('com.github.JakeWharton:ViewPagerIndicator:2.4.1') {
exclude module: 'support-v4'
}
After doing some research it seams that com.github.JakeWharton:ViewPagerIndicator:2.4.1 is already importing the android-support-v4.jar, from here your duplicate error. In order to fix it I recommend you to do the following changes:
remove android-support-v4.jar from libs folder
remove from gradle file the line compile files('libs/android-support-v4.jar').
Hope it fixes your problem.

I keep getting more than one library with package name [Android]

I keep getting
Error:Execution failed for task ':streamHdtv2:processDebugResources'.
> Error: more than one library with package name 'com.facebook'
You can temporarily disable this error with android.enforceUniquePackageName=false
However, this is temporary and will be enforced in 1.0
error. I have checked my build.gradle several times but I couldnt find any duplicate entry for package Facebook.
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.flashlight"
minSdkVersion 15
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':initActivity')
compile 'com.android.support:support-v4:22.2.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile project(':facebook')
}
You are importing one library twice
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile project(':facebook')
So remove one of the line and it will work.
and for more information have a look at below link
A library uses the same package as this project after importing Facebook SDK
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile project(':facebook')
Comment out any of the above line.
Use this
Error:Execution failed for task ':streamHdtv2:processDebugResources'.
> Error: more than one library with package name 'com.facebook'
You can temporarily disable this error with android.enforceUniquePackageName=false
However, this is temporary and will be enforced in 1.0
error. I have checked my build.gradle several times but I couldnt find any duplicate entry for package Facebook.
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.flashlight"
minSdkVersion 15
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':initActivity')
compile 'com.android.support:support-v4:22.2.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
}

Categories

Resources