java.util.zip.ZipException: duplicate entry: n.class - android

apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "[ MY PACKAGE ]"
minSdkVersion 15
targetSdkVersion 24
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'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
android {
useLibrary 'org.apache.http.legacy'
}
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.squareup.picasso:picasso:2.5.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.github.deano2390:android-viewbadger:1.0.0'
compile('com.jakewharton:butterknife:8.6.0') {
exclude module: 'support-compat'
}
compile project(':Library_MobilePaymentSDK')
testCompile 'junit:junit:4.12'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.github.aakira:expandable-layout:1.4.2#aar'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.google.android.gms:play-services:10.0.0'
compile 'com.google.firebase:firebase-messaging:10.0.0'
compile 'com.google.firebase:firebase-core:10.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile 'rongi.rotate-layout:rotate-layout:2.0.0'
compile 'com.roomorama:caldroid:3.0.1'
compile 'com.maksim88:PasswordEditText:v0.9'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'gun0912.ted:tedpermission:1.0.3'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jcmore2.appcrash:appcrash:1.1.0'
compile 'com.github.stfalcon:smsverifycatcher:0.2'
compile 'com.github.javiersantos:BottomDialogs:1.2.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
compile files('libs/mpaysdk-sandbox-1.0.28.jar')
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.jakewharton.butterknife'
this gradle file works in api 21 but when i run on api 19 the following error occured.
the following error occured:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: n.class
plz help me to solve this problem.

Solution#1:
In terminal, You can execute the following command in your root project folder:
./gradlew clean
Solution#2:
If you use Android Studio, then you can do it easily, Go to Menu
Build/Clean Project
It will update old dependencies
Solution#3:
You can add the following section to your build.gradle file:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}

Related

Unable to generate signed apk in Android Studio, getting error Error:Execution failed for task ':app:transformClassesWith

I am generating a signed apk in android studio but I'm getting following error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzp.class
This is my build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "net.jetserve.mocamandroid"
minSdkVersion 16
targetSdkVersion 26
versionCode 10000002
versionName "1.000000b"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
repositories {
maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
}
dependencies {
//HELP CENTER
compile group: 'com.zendesk', name: 'sdk', version: '1.11.0.1'
compile group: 'com.zendesk', name: 'sdk-providers', version: '1.11.0.1'
compile (group: 'com.zendesk', name: 'sdk', version: '1.8.0.1') {
exclude module: 'appcompat-v7';
exclude module: 'support-v4';
exclude module: 'design';
exclude module: 'recyclerview-v7'
}
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 project(':openCVLibrary320')
compile project(':libwebrtc')
compile project(':dialogLibrary')
//WebRTC socket
compile('io.socket:socket.io-client:1.0.0') {
exclude group: 'org.json', module: 'json'
}
//firebase
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-auth:11.6.0'
compile 'com.google.firebase:firebase-database:11.6.0'
compile 'com.firebaseui:firebase-ui-database:2.3.0'
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
compile 'com.firebaseui:firebase-ui-storage:2.3.0'
compile 'com.firebaseui:firebase-ui:2.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.25.0'
testCompile 'junit:junit:4.12'
compile 'de.hdodenhof:circleimageview:2.2.0'
//bottom navigation bar in settings activity
compile 'com.aurelhubert:ahbottomnavigation:1.3.3'
//ripple effect
compile 'com.balysv:material-ripple:1.0.2'
//compile 'com.github.bluejamesbond:textjustify-android:2.1.6'
//notification
compile 'com.google.firebase:firebase-messaging:11.6.0'
compile 'com.google.firebase:firebase-perf:11.6.0'
compile 'com.google.firebase:firebase-ads:11.6.0'
}
apply plugin: 'com.google.gms.google-services'
You should use 3.1.0 version.
compile 'com.firebaseui:firebase-ui-database:3.1.0'
compile 'com.firebaseui:firebase-ui:3.1.0'
compile 'com.firebaseui:firebase-ui-auth:3.1.0'
compile 'com.firebaseui:firebase-ui-storage:3.1.0'
If same problem coming then Remove
compile 'com.google.firebase:firebase-auth:11.6.0'

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformExceptionduplicate entry:

I am working with firebase notification and since this noon i am getting 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/gcm/PendingCallback$1.class
Build.gradle
apply plugin: 'com.android.application'
apply from: 'config.gradle'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "********"
minSdkVersion 17
targetSdkVersion 25
useLibrary 'org.apache.http.legacy'
versionCode 1
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
}
aaptOptions {
cruncherEnabled = false
}
buildTypes {
release {
shrinkResources true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
}
android.buildTypes.each { type ->
type.buildConfigField 'String', 'CHAT_SERVER_URL', "\"$chatServerUrl\""
}
repositories {
jcenter()
maven {
url 'http://tokbox.bintray.com/maven'
}
maven {
url 'https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/'
}
}
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 files('libs/picasso-2.5.2.jar')
compile("com.quickblox:quickblox-android-sdk-chat:2.5.1#aar") {
transitive = true
}
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'me.himanshusoni.chatmessageview:chat-message-view:1.0.7'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.20.0'
compile 'at.blogc:expandabletextview:1.0.3'
compile 'com.github.aakira:expandable-layout:1.6.0#aar'
compile 'com.opentok.android:opentok-android-sdk:2.10.+'
compile 'com.google.android.gms:play-services-gcm:10.2.6'
compile 'com.google.firebase:firebase-auth:10.2.6'
// compile 'com.google.android.gms.internal.zzanb:10.2.6'
compile 'com.google.firebase:firebase-invites:10.2.6'
compile 'com.google.firebase:firebase-messaging:10.2.6'
compile 'com.google.firebase:firebase-core:10.2.6'
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
compile 'com.firebaseui:firebase-ui:0.6.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.stripe:stripe-android:4.0.1'
compile 'com.parse:parse-android:1.13.0'
compile 'io.reactivex:rxjava:1.1.6'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
compile 'com.github.bmelnychuk:atv:1.2.+'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
You have to remove compile 'com.google.android.gms:play-services-gcm:10.2.6' from your module gradle file .
PendingCallback is the class that duplicate in both Firebase and old GCM .
Once you remove 'com.google.android.gms:play-services-gcm:10.2.6' from your gradle file you will find some compile errors that depends on 'com.google.android.gms:play-services-gcm:10.2.6' .
You have to replace that code with new google Firebase API code .
Hope it help you .

Gradle Errors After Adding Retrofit

For some reason, I am getting a strange error after adding Retrofit to a project that I inherited. If I remove Retrofit, the project builds but If I add it back then the error will re-appear.
How can I fix this issue? any suggestion is welcomed.
Here is the gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.domain.appname"
minSdkVersion 19
targetSdkVersion 24
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'
}
}
}
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-config:10.0.1'
compile 'com.google.firebase:firebase-invites:10.0.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.firebaseui:firebase-ui:1.0.1'
compile 'com.firebase:geofire-android:2.1.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.karumi:dexter:2.3.1'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-simplexml:2.1.0'
}
And here is a screenshot of the error message that I am getting.
https://dl.dropboxusercontent.com/u/15447938/downloads/gradle_error.png
I ran gradlew app:dependencies and it was pointing to "UnsupportedClassVersionError"
Caused by: java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
at org.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:71)
at org.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:51)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
This turns out to be some transitive dependencies that Simple XML converter have on Android core. I fixed the issue per this StackOverflow question like this
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile ('com.squareup.retrofit2:converter-simplexml:2.1.0'){
exclude group: 'xpp3', module: 'xpp3'
exclude group: 'stax', module: 'stax-api'
exclude group: 'stax', module: 'stax'
}

Could not get Resource guava.jar Tag mismatch

I am getting this error during gradle build.I am using android studio 2.1 beta 2.
Error:A problem occurred configuring project ':app'.
> Could not download guava.jar (com.google.guava:guava:19.0)
> Could not get resource 'https://jcenter.bintray.com/com/google/guava/guava/19.0/guava-19.0.jar'.
> Tag mismatch!
I have tried adding guava dependency in build.gradle but still it is showing same error. This is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
defaultConfig {
applicationId "mappr.co"
minSdkVersion 12
targetSdkVersion 23
versionCode 9
versionName "5.5"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided 'org.parceler:parceler:0.2.7'
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3') {
exclude module: "httpclient"
}
**compile 'com.google.guava:guava:19.0'**
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.mcxiaoke.volley:library:1.0.17'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'org.parceler:parceler-api:0.2.7'
compile 'com.github.PhilJay:MPAndroidChart:v2.0.9'
compile 'com.github.nkzawa:socket.io-client:0.5.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:support-v4:23.2.1'
}

Multidex duplicate entry with Joda Time

I just enabled Multidex support for my app and now I am getting this error from my Joda time dependency.
I am also using a library gson-jodatime-serialisers that depends on Joda. Not sure if it's causing the duplicate issue.
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: org/joda/time/base/AbstractDateTime.class
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.wake.social"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
manifestPlaceholders = [ localApplicationId:applicationId ]
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile('com.mikepenz:materialdrawer:2.9.8#aar') {
transitive = true
}
compile 'com.mikepenz.iconics:octicons-typeface:2.2.0#aar'
compile 'com.mikepenz:community-material-typeface:1.0.0#aar'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile('de.keyboardsurfer.android.widget:crouton:1.8.5#aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile 'com.afollestad:material-dialogs:0.7.4.2'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
compile 'com.github.satyan:sugar:1.3.1'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'eu.inloop:easygcm:1.4.0#aar'
compile 'me.leolin:ShortcutBadger:1.1.1#aar'
compile 'com.getbase:floatingactionbutton:1.9.0'
compile 'com.mobsandgeeks:android-saripaar:2.0-SNAPSHOT'
compile 'com.squareup:otto:1.3.7'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.github.navasmdc:MaterialDesign:1.5#aar'
compile 'com.github.traex.rippleeffect:library:1.3'
compile ("com.doomonafireball.betterpickers:library:1.6.0") {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'net.danlew:android.joda:2.7.2'
compile 'com.rengwuxian.materialedittext:library:2.1.3'
compile 'com.android.support:multidex:1.0.0'
compile ''com.fatboyindustrial.gson-jodatime-serialisers:gson-jodatime-serialisers:1.1.0' //this depends on it. Could be causing the problem.'
}
compile ''com.fatboyindustrial.gson-jodatime-serialisers:gson-jodatime-serialisers:1.1.0'
//this depends on it. Could be causing the problem.'
According to mvnrespository.com, this library depends on joda-time itself so it may be a duplicate entry
compile ("com.fatboyindustrial.gson-jodatime-serialisers:gson-jodatime-serializers:1.1.0") {
exclude module: 'joda-time'
}
Should do the trick

Categories

Resources