0

when i fix the most common issue i get this problem Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/graphics/BitmapCompat.class

my gradle class ::

 apply plugin: 'com.android.application'

android {
    //compileSdkVersion 25
    //buildToolsVersion "25.0.0"
    compileSdkVersion 21
    buildToolsVersion '24.0.3'
    defaultConfig {
        applicationId "com.scrollcoupons.com.kada"
      //  minSdkVersion 19
      //  targetSdkVersion 25
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true //important
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
  //  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 'com.android.support:support-v4:21.0.3'

   compile 'com.android.support:appcompat-v7:21.0.3'

   compile 'com.github.Yalantis:GuillotineMenu-Android:1.2'
    //compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.jakewharton:butterknife:8.8.1'
    //compile 'com.android.support:design:25.3.1'
   // testCompile 'junit:junit:4.12'
    //annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    //add external library
    compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'


}
Houssem Cherif
  • 221
  • 1
  • 11
  • This problem caused when there's combination with the butterknife dependency and "support-v4:21.0.3" library so to fix that i choose to remove the butterknife and that's Ok – Houssem Cherif Sep 09 '17 at 14:31

3 Answers3

1

you should exclude duplicate libs

   android {
    //compileSdkVersion 25
    //buildToolsVersion "25.0.0"
    compileSdkVersion 21
    buildToolsVersion '24.0.3'
    defaultConfig {
        applicationId "com.scrollcoupons.com.kada"
      //  minSdkVersion 19
      //  targetSdkVersion 25
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true //important
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

 ----->  configurations {
            all*.exclude group: 'com.android.support', module: 'support-v4'
            all*.exclude group: 'com.android.support', module: 'support-annotations'


    }
}
akshay_shahane
  • 4,423
  • 2
  • 17
  • 30
0

Step 1: In this case main hint is android/support/v4/graphics/BitmapCompat.class

Step 2: Searching for the class, in your case the "BitmapCompat.class" (in AndroidStudio just hit Ctrl+N on Windows or CMD-O on Mac)

Step 3: See which jar contains it - Android Studio will write it in the popup.

Step 4: Exclude it from all builds,

for example:

com.android.support:support-v4:_____

compile('your_conflicted_dependency')
{
     exclude module: 'support-v4'
}
0

Add the code in build.gradle

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
    all*.exclude group: 'com.android.support', module: 'support-annotations' 
}
avojak
  • 2,342
  • 2
  • 26
  • 32
edward
  • 1