0

I was trying generated a signed .APK however I'm passing through a problem. I already saw multiple similar questions regarding this error. I think this is a specific case for this error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForProdRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zzd.class

This is my build.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'

repositories {
    jcenter()
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
    maven { url "http://pyze.bintray.com/pyze-android" }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url 'https://jitpack.io' }
}

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "myapp"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled = true
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile ('com.android.support:design:25.3.1')

    compile('com.jakewharton:butterknife:8.5.1')
    compile('com.squareup.okhttp3:logging-interceptor:3.3.0')
    compile('com.squareup.retrofit2:retrofit:2.1.0')
    compile('com.squareup.retrofit2:converter-gson:2.1.0')
    compile('com.squareup.okhttp:okhttp:2.2.0')
    compile('com.squareup.okhttp:okhttp-urlconnection:2.2.0')
    compile('com.squareup.picasso:picasso:2.4.0')
    compile('net.danlew:android.joda:2.9.4.2')
    compile('com.michaelpardo:activeandroid:3.1.0-SNAPSHOT')
    compile('com.github.jkwiecien:EasyImage:2.0.2')
    compile('com.journeyapps:zxing-android-embedded:3.5.0')
    compile('com.pyze:PyzeLibrary:2.12.0')

    compile 'io.intercom.android:intercom-sdk-base:3.2.0'
    compile 'io.intercom.android:intercom-sdk-fcm:3.2.0'
    compile('com.facebook.android:facebook-android-sdk:4.22.0')
    compile('com.digits.sdk.android:digits:2.0.6@aar') {
        transitive = true;
    }
    compile('com.twitter.sdk.android:twitter:2.3.2@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }
    compile('com.twitter.sdk.android:tweet-composer:2.3.1@aar') {
        transitive = true;
    }

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    annotationProcessor('com.jakewharton:butterknife-compiler:8.5.1')
}

apply plugin: 'com.google.gms.google-services'

I tried to figure out what was the problem using this code to analyze the issue:

./gradlew clean app:dependencies

The result was:

compile - Classpath for compiling the main sources.
+--- com.android.support:multidex:1.0.1
+--- com.android.support:appcompat-v7:25.3.1
|    +--- com.android.support:support-annotations:25.3.1
|    +--- com.android.support:support-v4:25.3.1
|    |    +--- com.android.support:support-compat:25.3.1
|    |    |    \--- com.android.support:support-annotations:25.3.1
|    |    +--- com.android.support:support-media-compat:25.3.1
|    |    |    +--- com.android.support:support-annotations:25.3.1
|    |    |    \--- com.android.support:support-compat:25.3.1 (*)
|    |    +--- com.android.support:support-core-utils:25.3.1
|    |    |    +--- com.android.support:support-annotations:25.3.1
|    |    |    \--- com.android.support:support-compat:25.3.1 (*)
|    |    +--- com.android.support:support-core-ui:25.3.1
|    |    |    +--- com.android.support:support-annotations:25.3.1
|    |    |    \--- com.android.support:support-compat:25.3.1 (*)
|    |    \--- com.android.support:support-fragment:25.3.1
|    |         +--- com.android.support:support-compat:25.3.1 (*)
|    |         +--- com.android.support:support-media-compat:25.3.1 (*)
|    |         +--- com.android.support:support-core-ui:25.3.1 (*)
|    |         \--- com.android.support:support-core-utils:25.3.1 (*)
|    +--- com.android.support:support-vector-drawable:25.3.1
|    |    +--- com.android.support:support-annotations:25.3.1
|    |    \--- com.android.support:support-compat:25.3.1 (*)
|    \--- com.android.support:animated-vector-drawable:25.3.1
|         \--- com.android.support:support-vector-drawable:25.3.1 (*)
+--- com.android.support:design:25.3.1
|    +--- com.android.support:support-v4:25.3.1 (*)
|    +--- com.android.support:appcompat-v7:25.3.1 (*)
|    +--- com.android.support:recyclerview-v7:25.3.1
|    |    +--- com.android.support:support-annotations:25.3.1
|    |    +--- com.android.support:support-compat:25.3.1 (*)
|    |    \--- com.android.support:support-core-ui:25.3.1 (*)
|    \--- com.android.support:transition:25.3.1
|         +--- com.android.support:support-annotations:25.3.1
|         \--- com.android.support:support-v4:25.3.1 (*)
+--- com.jakewharton:butterknife:8.5.1
|    +--- com.jakewharton:butterknife-annotations:8.5.1
|    |    \--- com.android.support:support-annotations:25.1.0 -> 25.3.1
|    +--- com.android.support:support-annotations:25.1.0 -> 25.3.1
|    \--- com.android.support:support-compat:25.1.0 -> 25.3.1 (*)
+--- com.squareup.okhttp3:logging-interceptor:3.3.0
|    \--- com.squareup.okhttp3:okhttp:3.3.0
|         \--- com.squareup.okio:okio:1.8.0
+--- com.squareup.retrofit2:retrofit:2.1.0
|    \--- com.squareup.okhttp3:okhttp:3.3.0 (*)
+--- com.squareup.retrofit2:converter-gson:2.1.0
|    +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
|    \--- com.google.code.gson:gson:2.7
+--- com.squareup.okhttp:okhttp:2.2.0
|    \--- com.squareup.okio:okio:1.2.0 -> 1.8.0
+--- com.squareup.okhttp:okhttp-urlconnection:2.2.0
|    \--- com.squareup.okhttp:okhttp:2.2.0 (*)
+--- com.squareup.picasso:picasso:2.4.0 -> 2.5.2
+--- net.danlew:android.joda:2.9.4.2
|    \--- joda-time:joda-time:2.9.4
+--- com.michaelpardo:activeandroid:3.1.0-SNAPSHOT
+--- com.github.jkwiecien:EasyImage:2.0.2
|    +--- com.android.support:appcompat-v7:25.0.0 -> 25.3.1 (*)
|    \--- com.jakewharton.timber:timber:4.4.0
+--- com.journeyapps:zxing-android-embedded:3.5.0
|    +--- com.google.zxing:core:3.3.0
|    \--- com.android.support:support-v4:25.1.0 -> 25.3.1 (*)
+--- com.pyze:PyzeLibrary:2.12.0
|    +--- com.android.support:appcompat-v7:23.1.1 -> 25.3.1 (*)
|    +--- com.google.android.gms:play-services-gcm:9.6.1
|    |    +--- com.google.android.gms:play-services-base:9.6.1
|    |    |    +--- com.google.android.gms:play-services-basement:9.6.1 -> 10.2.1
|    |    |    |    \--- com.android.support:support-v4:24.0.0 -> 25.3.1 (*)
|    |    |    \--- com.google.android.gms:play-services-tasks:9.6.1 -> 10.2.1
|    |    |         \--- com.google.android.gms:play-services-basement:10.2.1 (*)
|    |    +--- com.google.android.gms:play-services-basement:9.6.1 -> 10.2.1 (*)
|    |    \--- com.google.android.gms:play-services-iid:9.6.1
|    |         +--- com.google.android.gms:play-services-base:9.6.1 (*)
|    |         \--- com.google.android.gms:play-services-basement:9.6.1 -> 10.2.1 (*)
|    +--- com.google.android.gms:play-services-ads:9.6.1
|    |    +--- com.google.android.gms:play-services-ads-lite:9.6.1
|    |    |    \--- com.google.android.gms:play-services-basement:9.6.1 -> 10.2.1 (*)
|    |    +--- com.google.android.gms:play-services-base:9.6.1 (*)
|    |    +--- com.google.android.gms:play-services-clearcut:9.6.1
|    |    |    +--- com.google.android.gms:play-services-base:9.6.1 (*)
|    |    |    \--- com.google.android.gms:play-services-basement:9.6.1 -> 10.2.1 (*)
|    |    +--- com.google.android.gms:play-services-basement:9.6.1 -> 10.2.1 (*)
|    |    \--- com.google.android.gms:play-services-gass:9.6.1
|    |         \--- com.google.android.gms:play-services-basement:9.6.1 -> 10.2.1 (*)
|    +--- com.google.firebase:firebase-messaging:9.6.1 -> 10.2.1
|    |    +--- com.google.android.gms:play-services-basement:10.2.1 (*)
|    |    +--- com.google.firebase:firebase-iid:10.2.1
|    |    |    +--- com.google.android.gms:play-services-basement:10.2.1 (*)
|    |    |    \--- com.google.firebase:firebase-common:10.2.1
|    |    |         +--- com.google.android.gms:play-services-basement:10.2.1 (*)
|    |    |         \--- com.google.android.gms:play-services-tasks:10.2.1 (*)
|    |    \--- com.google.firebase:firebase-common:10.2.1 (*)
|    \--- com.android.support:support-v4:23.1.1 -> 25.3.1 (*)
+--- io.intercom.android:intercom-sdk-base:3.2.0
|    +--- com.android.support:design:25.3.1 (*)
|    +--- com.android.support:appcompat-v7:25.3.1 (*)
|    +--- com.android.support:animated-vector-drawable:25.3.1 (*)
|    +--- com.android.support:support-vector-drawable:25.3.1 (*)
|    +--- com.android.support:support-v4:25.3.1 (*)
|    +--- com.android.support:support-annotations:25.3.1
|    +--- com.android.support:recyclerview-v7:25.3.1 (*)
|    +--- com.intercom:android-composer:1.0.2
|    \--- com.intercom:android-composer-gallery:1.0.2
|         \--- com.android.support:appcompat-v7:25.1.1 -> 25.3.1 (*)
+--- io.intercom.android:intercom-sdk-fcm:3.2.0
|    +--- io.intercom.android:intercom-sdk-base:3.2.0 (*)
|    \--- com.google.firebase:firebase-messaging:10.2.1 (*)
+--- com.facebook.android:facebook-android-sdk:4.22.0
|    +--- com.android.support:support-v4:25.0.0 -> 25.3.1 (*)
|    +--- com.android.support:appcompat-v7:25.0.0 -> 25.3.1 (*)
|    +--- com.android.support:cardview-v7:25.0.0
|    |    \--- com.android.support:support-annotations:25.0.0 -> 25.3.1
|    +--- com.android.support:customtabs:25.0.0
|    |    +--- com.android.support:support-compat:25.0.0 -> 25.3.1 (*)
|    |    \--- com.android.support:support-annotations:25.0.0 -> 25.3.1
|    \--- com.parse.bolts:bolts-android:1.4.0
|         +--- com.parse.bolts:bolts-tasks:1.4.0
|         \--- com.parse.bolts:bolts-applinks:1.4.0
|              \--- com.parse.bolts:bolts-tasks:1.4.0
+--- com.digits.sdk.android:digits:2.0.6
|    +--- com.squareup.retrofit2:retrofit-mock:2.0.2
|    |    \--- com.squareup.retrofit2:retrofit:2.0.2 -> 2.1.0 (*)
|    +--- com.twitter.sdk.android:twitter-core:2.3.0 -> 2.3.1
|    |    +--- com.google.code.gson:gson:2.6.1 -> 2.7
|    |    +--- com.squareup.retrofit2:converter-gson:2.0.2 -> 2.1.0 (*)
|    |    +--- com.squareup.okhttp3:okhttp:3.2.0 -> 3.3.0 (*)
|    |    +--- io.fabric.sdk.android:fabric:1.3.+ -> 1.3.16
|    |    \--- com.squareup.retrofit2:retrofit:2.0.2 -> 2.1.0 (*)
|    +--- io.fabric.sdk.android:fabric:1.3.16
|    \--- com.crashlytics.sdk.android:answers-shim:0.0.4
+--- com.twitter.sdk.android:twitter:2.3.2
|    +--- com.twitter.sdk.android:tweet-composer:2.3.1
|    |    +--- com.twitter:twitter-text:1.13.0
|    |    +--- io.fabric.sdk.android:fabric:1.3.14 -> 1.3.16
|    |    +--- com.twitter.sdk.android:twitter-core:2.3.0 -> 2.3.1 (*)
|    |    \--- com.squareup.picasso:picasso:2.5.2
|    +--- com.twitter.sdk.android:twitter-core:2.3.1 (*)
|    \--- com.twitter.sdk.android:tweet-ui:2.3.2
|         +--- com.android.support:support-v4:23.1.1 -> 25.3.1 (*)
|         +--- com.twitter.sdk.android:twitter-core:2.3.1 (*)
|         \--- com.squareup.picasso:picasso:2.5.2
+--- com.crashlytics.sdk.android:crashlytics:2.6.7
|    +--- com.crashlytics.sdk.android:beta:1.2.4
|    |    \--- io.fabric.sdk.android:fabric:1.3.16
|    +--- io.fabric.sdk.android:fabric:1.3.16
|    +--- com.crashlytics.sdk.android:answers:1.3.12
|    |    \--- io.fabric.sdk.android:fabric:1.3.16
|    \--- com.crashlytics.sdk.android:crashlytics-core:2.3.16
|         +--- io.fabric.sdk.android:fabric:1.3.16
|         \--- com.crashlytics.sdk.android:answers:1.3.12 (*)
+--- com.twitter.sdk.android:tweet-composer:2.3.1 (*)
\--- com.google.firebase:firebase-core:9.0.0
     \--- com.google.firebase:firebase-analytics:9.0.0
          +--- com.google.android.gms:play-services-basement:9.0.0 -> 10.2.1 (*)
          +--- com.google.firebase:firebase-common:9.0.0 -> 10.2.1 (*)
          \--- com.google.firebase:firebase-analytics-impl:9.0.0
               +--- com.google.android.gms:play-services-base:9.0.0 -> 9.6.1 (*)
               +--- com.google.android.gms:play-services-basement:9.0.0 -> 10.2.1 (*)
               +--- com.google.firebase:firebase-iid:9.0.0 -> 10.2.1 (*)
               \--- com.google.firebase:firebase-common:9.0.0 -> 10.2.1 (*)

Another detail that may interfere in this issue, my IDE is showing this message:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.3.1, 25.0.0. Examples include com.android.support:animated-vector-drawable:25.3.1 and com.android.support:cardview-v7:25.0.0

I believe some of those libraries are conflicting with each other regarding GMS version, but unfortunately I could not figure out which libraries and how to solve the problem.

Thank you in advance

Agna JirKon Rx
  • 2,321
  • 2
  • 29
  • 44

1 Answers1

1

The problem is that you have several dependencies which use different versions of the Support Libraries and these all differ from the version which you explicitly state for your project. You need to standardize all of these to a single version. Ideally, you want to use the most recent version of the Support Libraries.

The first step is to make sure you are using the most recent version of all of your dependencies. If you are lucky, this might fix the problem immediately.

If you still get similar errors, then you need to override the Support Library version. You can do this in two ways:

  1. Manually exclude transitive dependencies from each dependency which uses the support library. You should do this selectively, rather than whole sale. For example

    compile 'com.jakewharton:butterknife:8.5.1', {
       exclude group: 'com.android.support'
    }
    
  2. Override the Support Libarary version as described in this answer.

If you need further help, you should google the error message that says "All com.android.support libraries must use the exact same version specification". This will give you better results than "java.util.zip.ZipException: duplicate entry:".

Community
  • 1
  • 1
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268