0

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?

Nuno
  • 61
  • 1
  • 10
  • Since that class has been obsolete for quite some time, you should have zero copies of it in your app, and certainly not more than one. You will need to look at your source code and your dependencies to see where these editions of this class are coming from. – CommonsWare Apr 14 '17 at 19:36
  • i just try to delete some dependences that could be that class, but its also the same error. Now i edit this post and put all of my dependences there. if you could see maybe you can help me more @CommonsWare – Nuno Apr 14 '17 at 19:45
  • "i just try to delete some dependences that could be that class" -- make sure that you clean your project (Build > Clean Project from the Android Studio main menu). Beyond that, work on replacing every one of those `compile files(...)` statements. They should either reference artifacts (the way the rest of your lines do) or be deleted (such as getting rid of `compile files('libs/android-support-v4.jar')`, which will add hundreds of duplicate classes to your project). – CommonsWare Apr 14 '17 at 19:48
  • You have multiple conflicting dependencies. I suggest you group your dependencies, put comments in the file, and where you're using something like play services, use a variable for the version number to ensure that they all have matching versions. You can run `gradlew app:dependencies` to see a tree view/graph of all your dependencies. – Mark Apr 14 '17 at 20:00
  • I just delete the `compile files...` and clean the project but nothinghas changed @CommonsWare – Nuno Apr 14 '17 at 21:05
  • Where I can run `gradlew app:dependencies` @Mark – Nuno Apr 14 '17 at 21:11

1 Answers1

0

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'
    })
}
Jared Burrows
  • 54,294
  • 25
  • 151
  • 185