Search code examples
androidandroid-studiogradleandroid-studio-2.2geopoints

duplicate entry: com/google/android/maps/GeoPoint.class


I´m using Android studio and when I Generate a signed APK its show me an error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/maps/GeoPoint.class

my dependences:

dependencies {

    //compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    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/google-api-client-1.10.3-beta.jar')
    compile files('libs/google-http-client-1.10.3-beta.jar')
    compile files('libs/google-http-client-android2-1.10.3-beta.jar')
    compile files('libs/google-oauth-client-1.10.1-beta.jar')
    compile files('libs/gson-2.1.jar')
    compile files('libs/guava-11.0.1.jar')
    compile files('libs/jackson-core-asl-1.9.4.jar')
    compile files('libs/jsr305-1.3.9.jar')
    compile files('libs/protobuf-java-2.2.0.jar')
    compile files('libs/android-support-v4.jar')
    //compile files('libs/android-google-maps-api13.jar')
    //apply plugin: 'com.google.gms.google-services'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.android.support:support-v4:24.1.0'
    compile 'com.google.android.gms:play-services-auth:9.6.1'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.google.android.gms:play-services:9.6.1'
    compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
    compile 'com.koushikdutta.ion:ion:2.1.7'
    compile 'com.squareup:otto:1.3.8'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'junit:junit:4.12'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
    testCompile 'junit:junit:4.12'

}

how I fix it?


Solution

  • I have done the following:

    • Removed duplicated jar vs maven dependencies
    • Organized configurations: compile, testCompile, androidTestCompile
    • Make sure testCompile dependencies and compile dependencies aren't mixed

    Try this:

    dependencies {  
        // apply plugin: 'com.google.gms.google-services'
        // compile 'com.facebook.android:facebook-android-sdk:[4,5)'
        // compile 'com.google.android.gms:play-services:9.6.1' <-- this is too big, only use the modules you need
        // compile 'junit:junit:4.12' <-- wrong configuration
        // compile files('libs/android-google-maps-api13.jar')
        // compile files('libs/android-support-v4.jar') <-- you already have this added
        // compile fileTree(include: ['*.jar'], dir: 'libs') <- try not to use jars
    
        compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
        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.github.bumptech.glide:glide:3.7.0'
        compile 'com.google.android.gms:play-services-auth:9.6.1'
        compile 'com.koushikdutta.ion:ion:2.1.7'
        compile 'com.mcxiaoke.volley:library:1.0.19'
        compile 'com.squareup.okhttp3:logging-interceptor:3.4.0'
        compile 'com.squareup.retrofit2:converter-gson:2.1.0'
        compile 'com.squareup.retrofit2:retrofit:2.1.0'
        compile 'com.squareup:otto:1.3.8'
        compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
        // Try not to use jars, use maven dependencies 
        compile files('libs/google-api-client-1.10.3-beta.jar')
        compile files('libs/google-http-client-1.10.3-beta.jar')
        compile files('libs/google-http-client-android2-1.10.3-beta.jar')
        compile files('libs/google-oauth-client-1.10.1-beta.jar')
        compile files('libs/gson-2.1.jar')
        compile files('libs/guava-11.0.1.jar')
        compile files('libs/jackson-core-asl-1.9.4.jar')
        compile files('libs/jsr305-1.3.9.jar')
        compile files('libs/protobuf-java-2.2.0.jar')
    
        testCompile 'junit:junit:4.12'
    
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
    }