6

I just updated my support library from 23.0.0 to 23.1.0 and now when I build the project, I get this error :

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

Here is my app level build.gradle:

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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}


apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion "23"
    defaultConfig {
        applicationId 'com.galleri5.android'
        multiDexEnabled true
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 6
        versionName "0.6"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


repositories {
    mavenCentral()
    mavenLocal()
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:23.1.0'
    compile 'com.facebook.android:facebook-android-sdk:4.3.0'
    compile 'com.etsy.android.grid:library:1.0.5'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'
    compile 'com.android.support:cardview-v7:23.1.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.github.clans:fab:1.6.1'
    compile 'uk.co.chrisjenx:calligraphy:2.1.0'
    compile 'com.google.android.gms:play-services-analytics:8.1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true;
    }
}

What am I getting this error? I want to use the latest version of support library. How can I fix this issue? I read this SO thread and the solution didn't work. It gave more errors in my codebase. Also, I am not using JARs. Any help would be highly appreciated. Thanks.

Community
  • 1
  • 1
Amit Tiwari
  • 3,684
  • 6
  • 33
  • 75
  • 1
    Cleaning the project should help And set `compileSdkVersion 23 buildToolsVersion "23.0.1"` – IntelliJ Amiya Oct 27 '15 at 07:43
  • tried that. still getting the same error. – Amit Tiwari Oct 27 '15 at 07:48
  • In terminal execute in root project folder: ./gradlew clean http://stackoverflow.com/questions/33209631/errorexecution-failed-for-task-apptransformclasseswithjarmergingfordebug http://stackoverflow.com/questions/32968171/android-apptransformclasseswithjarmergingfordebug-failed-zipexception-dupli – Chaudhary Amar Oct 27 '15 at 07:59
  • 1
    yeah, it works now. Thanks. cleaning the project works. – Amit Tiwari Oct 27 '15 at 08:08
  • I hope this [answer](http://stackoverflow.com/questions/33209631/errorexecution-failed-for-task-apptransformclasseswithjarmergingfordebug) help you... – Reza Nazeri Dec 06 '15 at 11:00

2 Answers2

8

I ran into the same problem in my React Native Android project, and this is what made it work for me:

cd android

./gradlew clean
knowbody
  • 8,106
  • 6
  • 45
  • 70
0

You need to add the exclude group: on your support V7 like this one:

compile ('com.android.support:appcompat-v7:19.+' ) {
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    exclude group: 'com.android.support'
}
lucasddaniel
  • 1,779
  • 22
  • 22