gaurav tiwari
gaurav tiwari

Reputation: 1093

ZipExcepton: duplicate entry: com/google/android/gms/internal/zzpi.class

I am running into this issue every time I am trying to run my project.
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/internal/zzpi.class

Here is my build script:

    buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        // The Fabric Gradle plugin uses an open ended version to react
        // quickly to Android tooling updates
        classpath 'io.fabric.tools:gradle:1.15.2'
    }
}
apply plugin: 'com.android.application'
//Put Fabric plugin after Android plugin

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/commons-collections4-4.0.jar')
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    compile files('libs/graphview-3.1.jar')
    testCompile 'junit:junit:4.12'
    compile project(':progresslibrary')
    compile files('libs/gson-2.6.2.jar')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
        transitive = true;
    }
    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.2'
    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.2'



    compile 'com.android.support:multidex:1.0.0'
    compile 'com.hrules:charter:1.4.0'
    compile 'com.github.hotchemi:permissionsdispatcher:2.1.2'
    //noinspection GradleCompatible
    compile 'com.google.android.gms:play-services-analytics:8.4.0'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.hrules:charter:1.4.0'
    compile 'com.google.android.gms:play-services-analytics:8.4.0'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15'
    compile 'com.github.hotchemi:permissionsdispatcher:2.1.2'
    compile 'com.amazonaws:aws-android-sdk-core:2.+'
    compile 'com.amazonaws:aws-android-sdk-s3:2.+'
    compile 'eu.the4thfloor.volley:com.android.volley:2015.05.28'
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'
    compile 'com.snappydb:snappydb-lib:0.5.2'
    compile 'com.google.android.gms:play-services-auth:9.4.0'
    compile 'com.google.android.gms:play-services-plus:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.android.gms:play-services-location:8.4.0'
    compile 'com.wdullaer:materialdatetimepicker:2.2.0'
    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
    compile 'com.shamanland:fab:0.0.8'
    compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
    compile 'com.android.support:design:23.2.0'
    compile 'com.android.support:support-v4:23.2.0'
    compile 'com.android.support:recyclerview-v7:23.2.0'
    compile 'com.android.support:cardview-v7:23.2.0'
    compile 'org.jsoup:jsoup:1.9.1'
    compile 'com.flurry.android:analytics:6.2.0'
    compile 'com.google.android.gms:play-services-fitness:8.4.0'
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
    compile 'com.github.danielemaddaluno.androidupdatechecker:library:1.0.2'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
}

android {
    packagingOptions {
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
    }
}
apply plugin: 'build-announcements'

please tell me what is wrong with my build script

Upvotes: 0

Views: 1299

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191738

At a quick glance, I can tell you that the problem exists in Google Play Services. And I am going to guess that these all need to be the same version (grouped by same version here).

compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'

compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'

In order to efficiently do that, you can define an ext block in you Gradle file for keeping the version numbers consistent.

Additional note: This line compile fileTree(include: ['*.jar'], dir: 'libs')... It says compile all JAR files in the libs/ directory, therefore, these lines are pointless, and you can remove them while you try to identify where the error occurs.

compile files('libs/commons-collections4-4.0.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile files('libs/graphview-3.1.jar')
compile files('libs/gson-2.6.2.jar')

Sample build.gradle

ext {
    // Variables to keep libraries consistent
    supportLibrary = "23.2.0"
    googlePlayServicesVersion = '9.4.0'

    // Support Libraries dependencies
    supportDependencies = [
            design           :         "com.android.support:design:${supportLibrary}",
            recyclerView     :         "com.android.support:recyclerview-v7:${supportLibrary}",
            cardView         :         "com.android.support:cardview-v7:${supportLibrary}",
            appCompatV7      :         "com.android.support:appcompat-v7:${supportLibrary}"
    ]

    googlePlayServicesDepends = [
            analytics   : "com.google.android.gms:play-services-analytics:${googlePlayServicesVersion}"
            plus        : "com.google.android.gms:play-services-plus:${googlePlayServicesVersion}"
            location    : "com.google.android.gms:play-services-location:${googlePlayServicesVersion}"
            fitness     : "com.google.android.gms:play-services-fitness:${googlePlayServicesVersion}"
            appindexing : "com.google.android.gms:play-services-appindexing:${googlePlayServicesVersion}"
            auth        : "com.google.android.gms:play-services-auth:${googlePlayServicesVersion}"
            gcm         : "com.google.android.gms:play-services-gcm:${googlePlayServicesVersion}"
    ]

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    // compile supportDependencies.appCompatV7
    // compile supportDependencies.recyclerView

    // recommended - includes those above
    compile supportDependencies.design

    // extras
    compile supportDependencies.cardView

    // The correct Volley library
    compile 'com.android.volley:volley:1.0.0'

    compile 'com.squareup.picasso:picasso:2.5.2'
    compile "com.google.code.gson:gson:2.6.2"

    // Google Play Services
    compile googlePlayServicesDepends.location
    // TODO: Add others

}

Upvotes: 1

Related Questions