Java – Jar merge for debugging with android throwing duplicate entries?

Jar merge for debugging with android throwing duplicate entries?… here is a solution to the problem.

Jar merge for debugging with android throwing duplicate entries?

I’m getting this error when trying to run my build:

    Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.> com.android.build.transform.api.TransformException: java.util.zip.ZipException : duplicate entry: android/support/annotation/AnimatorRes.class

This is my build.gradle

dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.1.0'
        compile 'com.android.support:design:23.1.0'
        compile('com.digits.sdk.android:digits:1.9.0@aar') {
            transitive = true;
        }
        compile 'com.parse.bolts:bolts-android:1.+'
        compile 'com.parse:parse-android:1.+'
        compile 'com.android.support:cardview-v7:23.1.0'
        compile 'me.zhanghai.android.materialprogressbar:library:1.0.2'
        compile 'com.android.support:support-v4:23.1.0'
        compile 'com.google.android.gms:play-services-identity:8.1.0'
        compile 'com.google.android.gms:play-services-plus:8.1.0'
        compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
        compile 'com.anjlab.android.iab.v3:library:1.0.+@aar'
    }

Here is a picture of my library

enter image description here

I hope someone here can help me figure out what’s wrong. I’m using Android Studio.

Solution

Try excluding support-v4

because google-play-services already includes support-v4

compile ('com.google.android.gms:play-services:8.1.0')
{
     exclude group: 'com.android.support', module: 'support-v4'
}

If it doesn’t work
Clean up the project and rebuild it.

Otherwise, try setting multiDexEnabled in the gradle file

defaultConfig {
    multiDexEnabled true
}

Related Problems and Solutions