ZipException: duplicate entry: android/support/annotation/AttrRes.class - android

I am facing, Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: android/support/annotation/AttrRes.class
build.gradle file (main project)
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-location:7.8.0'
compile 'com.google.android.gms:play-services-maps:7.8.0'
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.google.android.gms:play-services-nearby:7.8.0'
compile ('com.android.support:recyclerview-v7:+') {
exclude module: 'support-v4'
}
compile 'com.firebase:firebase-client-android:2.3.1+'
compile ('com.android.support:cardview-v7:22.0.+') {
exclude module: 'support-v4'
}
compile ('com.squareup.okhttp:okhttp:2.4.0') {
exclude module: 'support-v4'
}
compile ('com.squareup.picasso:picasso:2.5.2') {
exclude module: 'support-v4'
}
compile ('com.squareup.retrofit:retrofit:2.0.0-beta1') {
exclude module: 'support-v4'
}
compile('com.squareup.retrofit:converter-gson:2.0.0-beta1') {
exclude module: 'gson'
}
compile('com.segment.analytics.android:all:2.5.1#aar') {
transitive = true
exclude module: 'support-v4'
}
compile ('com.android.support:design:22.2.0') {
exclude module: 'support-v4'
}
compile('com.uservoice:uservoice-android-sdk:1.2.+') {
exclude module: 'commons-logging'
exclude module: 'httpcore'
exclude module: 'httpclient'
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
compile project(':contactsChipView')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile project(':facebook-android-sdk-4.0.1')
compile ('com.android.support:multidex:1.0.0'){
exclude module: 'support-v4'
}
Files in /libs directory (main project):
gson-2.2.3.jar
Parse-1.9.2.jar
YoutubeAnddroidPlayerApi.jar
Files in /libs directory (facebook module):
android-support-v4.jar
bolts.jar
As you can see the above gradle file, I have tried adding exclude for almost all dependencies. But still, no luck.
I also tried changing build tools from 22.0.1 to 22.0.0, even this didn't work.
I went through other posts, but no luck.
Anybody knows how to solve this?

Related

React Native not compile in release

I compile my proeject with react-native-camera and another libs to android.
when I try to compile my project in release with this code:
compile (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
exclude group: "com.android.support"
}
and I receive this error:
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/facebook/infer/annotation/Assertions.class
so I try to compile add infe-anotation to not compile
compile (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
exclude group: "com.android.support"
exclude group: "com.facebook.infer.annotation"
}
compile to release but not run the app.

Error:Conflict with dependency 'com.android.support:support-v4' in project ':app'. Resolved versions for app (25.3.1) and test app (23.1.1) differ

I get this error every time i am trying to add dependency of Esspreso UI test library by the following dependency to use it in developing UI test for RecyclerView to get RecyclerViewActions.
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'
while deleting previous dependency gradle is building perfectly
can anyone help me selving this problem??
Sample from my gradle :
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.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
testCompile 'junit:junit:4.12'
compile 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'
compile 'com.google.android.exoplayer:exoplayer:r2.2.0'
androidTestCompile( 'com.android.support.test.espresso:espresso-intents:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile( 'com.android.support.test:rules:0.5', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile ('com.android.support.test:runner:0.5', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile ('com.android.support.test.espresso:espresso-web:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile( 'com.android.support.test.espresso:espresso-contrib:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
Update
After googling for an hour I found the solution within Vogella by
setting this dependency as following:
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
This would solve your problem:
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
exclude group: 'com.google.code.findbugs'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude module: 'recyclerview-v7'
}
You need to just exclude every library you have already provided in build.gradle

Error:Conflict with dependency 'com.android.support: when update from 23.1.1 to 23.4.0

I have upgrade my build.gradle from
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
to
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
However, the existence of below test libraries cause some gradle sync error
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2')
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
The error is
Error:Conflict with dependency 'com.android.support:appcompat-v7'. Resolved versions for app (23.4.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'com.android.support:design'. Resolved versions for app (23.4.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.4.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
How could I resolve this conflicts? Should I upgrade my test libraries as well (how to know which version to upgrade to)?
I perform various exclusion to resolve the problem. I hope there's a better answer (e.g. upgrade the test library?).
androidTestCompile ('com.android.support.test:runner:0.5') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:rules:0.5') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'design'
exclude module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test.espresso:espresso-web:2.2.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}

app:transformClassesWithJarMergingForDebug FAILED

when I try to run the app I am getting this error
before
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzsk.class
Now
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzqz$zza.class
I referred this,this and this. Tried the solutions mentioned there. Still I am far away from solving the Issue.
Please have a look on the app build gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile('com.android.support:appcompat-v7:23.1.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile('com.android.support:recyclerview-v7:23.1.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile('com.android.support:cardview-v7:23.1.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile('com.android.support:design:23.1.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.clevertap.android:clevertap-android-sdk:2.0.11'
compile 'com.android.support:support-v4:23.1.1'
compile('com.google.android.gms:play-services-analytics:8.3.0')
{
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.google.guava'
}
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile "com.squareup.picasso:picasso:2.4.0"
compile('com.google.android.gms:play-services-gcm:8.3.0') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.google.guava'
}
compile('com.google.android.gms:play-services:8.3.0') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.google.guava'
}
compile 'de.hdodenhof:circleimageview:1.3.0'
compile project(':volley')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile 'com.android.support:multidex:'
apply plugin: 'com.google.gms.google-services'
}
I am happy to provide more information if needed.
UPDATE
When I comment compile 'com.clevertap.android:clevertap-android-sdk:2.0.11' It is working fine.
please check if some of your dependencies have multidex as dependency and exclude it. For example for Facebook SDK: you have this
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
change to this
compile('com.facebook.android:facebook-android-sdk:4.7.0') {
exclude group: 'com.android.support', module: 'multidex'
}
and check for other also.
Solved the issue by updating the com.google.android.gms:play-services version
from 8.3.0 to 8.4.0

Proguard issue Roboguice duplicate import

I am running to an issue when i run my gradle build. It seems like there are duplicate dependencies getting imported but finding it hard to debug, any suggestions would be great.
Error:Execution failed for task ':proguardDebug'.
java.io.IOException: Can't write [.......\build\intermediates\classes-proguard\debug\classes.jar] (Can't read [.......gradle\caches\modules-2\files-2.1\org.roboguice\roboguice\3.0.1\24e814f35d5cc28eaa7e9f07a50ea69deeb2b544\roboguice-3.0.1.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [roboguice-3.0.1.jar:javax/inject/Inject.class]))
dependencies {
repositories {
mavenCentral()
}
compile 'com.google.android:multidex:0.1'
compile files('libs/aws-android-sdk-1.7.1.1.jar')
compile 'com.makeramen:roundedimageview:1.3.0'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.squareup.picasso:picasso:2.3.3'
compile 'org.codehaus.jackson:jackson-core-asl:1.9.13'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.google.android.gms:play-services:+'
compile 'com.androidmapsextensions:android-maps-extensions:2.1.+'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:20.+'
compile 'com.jeremyfeinstein.slidingmenu:library:1.3#aar'
compile('com.commonsware.cwac:camera-v9:0.6.+') {
exclude module: 'support-v4'
}
compile 'com.squareup:otto:1.3.6'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.okio:okio:1.2.0'
compile project(':libraries:facebook')
compile files('libs/Catalano.Core.jar')
compile files('libs/Catalano.Android.Image.jar')
compile files('libs/Catalano.Math.jar')
compile 'org.roboguice:roboguice:3.+'
provided 'org.roboguice:roboblender:3.+'
compile 'com.google.code.findbugs:jsr305:3.0.0'
compile 'com.android.support.test.espresso:espresso-core:2.0'
compile 'com.android.support.test:testing-support-lib:0.1'
compile 'com.android.support.test.espresso:espresso-contrib:2.0'
compile 'junit:junit:4.12'
compile 'org.hamcrest:hamcrest-core:1.1'
compile 'org.hamcrest:hamcrest-library:1.1'
compile 'org.hamcrest:hamcrest-integration:1.1'
compile('org.robolectric:robolectric:2.4') {
exclude module: 'classworlds'
exclude module: 'commons-logging'
exclude module: 'httpclient'
exclude module: 'maven-artifact'
exclude module: 'maven-artifact-manager'
exclude module: 'maven-error-diagnostics'
exclude module: 'maven-model'
exclude module: 'maven-project'
exclude module: 'maven-settings'
exclude module: 'plexus-container-default'
exclude module: 'plexus-interpolation'
exclude module: 'plexus-utils'
exclude module: 'wagon-file'
exclude module: 'wagon-http-lightweight'
exclude module: 'wagon-provider-api'
}
You can figure out what is pulling in dependencies by running this command in your project root:
./gradlew app:androidDependencies
You will get output similar to this:
Also, don't forget to check your app/libs/ folder to ensure it's empty if you're pulling everything in with Gradle.

Categories

Resources