43

Good day. After updating google repository in AndroidStudio, I have an issue

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

I'm trying to exclude group android.support from play-services, it did not help. When I started my project on another PC I have:

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

my build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "ru.alexeyk.myevents"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 16
        versionName "1.121"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.github.nkzawa:socket.io-client:0.4.2') {
        exclude group: 'org.json', module: 'json'
    }
    compile files('libs/sentry-1.1.4.jar')
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:support-annotations:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.android.support:cardview-v7:23.1.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
    compile 'com.github.machinarius:preferencefragment:0.1.2'
    compile 'com.edmodo:cropper:1.0.1'
    compile 'com.makeramen:roundedimageview:2.1.1'
    compile 'org.ocpsoft.prettytime:prettytime:4.0.0.Final'
    compile 'com.yandex.android:mobmetricalib:2.00@aar'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.google.android.gms:play-services-ads:8.1.0'
    compile 'com.google.android.gms:play-services-analytics:8.1.0'
    compile 'com.google.android.gms:play-services-identity:8.1.0'
    compile 'com.google.android.gms:play-services-gcm:8.1.0'
}
Chepech
  • 5,258
  • 4
  • 47
  • 70
Alexei Korshun
  • 1,248
  • 1
  • 9
  • 14

11 Answers11

70

In terminal execute in root project folder:

./gradlew clean

It helped me.

Alexei Korshun
  • 1,248
  • 1
  • 9
  • 14
  • I saw this error when migrating my project from Studio 1.5 to 2.0 beta. this got rid of the error for me, then I got a "could not delete classes.jar" which was fixed by this http://stackoverflow.com/questions/32914499/error-execution-failed-for-task-appclean-unable-to-delete-file and then everything built. thanks! – chiliNUT Jan 19 '16 at 15:01
  • 1
    @dens14345 what os you use? – Alexei Korshun Feb 14 '16 at 05:13
  • 1
    Im using windows 8.1 64 bit, android studio version: 1.5 – dens14345 Feb 15 '16 at 05:47
  • 3
    @dens14345 try .\gredlew.bat clean – Alexei Korshun Feb 19 '16 at 10:13
  • 5
    i tried gradlew clean but it's not working.i get same error. any solution – Ram May 03 '16 at 07:08
  • 6
    NOT Working in my case – Shoeb Siddique Oct 07 '16 at 11:35
  • I am getting the error, firebase duplicate entry zzcl.class, and this did not solve my problem. Not complaining, just a heads up if anyone else comes unto this problem – PGMacDesign Oct 27 '16 at 21:40
  • 8
    This obviously isn't a solution to any actual problem. It's just rebuilding the project. – CaptRespect Nov 12 '16 at 14:52
  • he's saying to clean your project. You can use ```gradlew ``` in the terminal tab in Android Studio, or anywhere your gradle wrapper is. If you want ```gradle``` available globally, add it to your path – Saik Caskey Apr 18 '17 at 16:01
16

AndroidStudio Menu:

Build/Clean Project

Update old dependencies

SergioLucas
  • 1,094
  • 8
  • 16
15

All the above not working for me.. Because I am using Facebook Ad dependency..

Incase If anybody using this dependency compile 'com.facebook.android:audience-network-sdk:4.16.0'

Try this code instead of above

compile ('com.facebook.android:audience-network-sdk:4.16.0'){
exclude group: 'com.google.android.gms'
}
Ranjithkumar
  • 16,071
  • 12
  • 120
  • 159
9

Open your system command prompt/terminal -> Go to your Project folder path (root project folder ) -> Execute following command : command :- gradlew clean or ./gradlew clean

Make sure that all your gradle dependencies are of same version. -> Example :- your appcompat and recyclerview dependencies should have same version.

-> Change your gradle dependencies to same version like :-

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'

-> Rebuild your project and it will work fine.

Priya Jagtap
  • 1,023
  • 13
  • 19
  • 1
    In my case I got caught with different versions for google play services and firebase ads. Firebase now falls under the google play services umbrella and therefore has the same version. – Bulwinkel Nov 24 '16 at 22:59
  • This worked for me. cleaned and changed `compile 'com.android.support:recyclerview-v7:+' ` to `compile 'com.android.support:recyclerview-v7:24.2.1' ` in apps build.gradle. – gnyrfta Feb 13 '18 at 21:16
6

Use project root in terminal like this:-/Users/rajnish/Desktop/RankProjects/ProjectCloud

After that enter this command ./gradlew clean

It will work.

Rank
  • 900
  • 9
  • 17
5

There may be different reason for reported issue, few days back also face this issue 'duplicate jar', after upgrading studio. From all stackoverflow I tried all the suggestion but nothing worked for me.

But this is for sure some duplicate jar is there, For me it was present in one library libs folder as well as project libs folder. So I removed from project libs folder as it was not required here. So be careful while updating the studio, and try to understand all the gradle error.

u_pendra
  • 908
  • 1
  • 10
  • 25
1

I got this error because I did not have the correct line in my build.gradle. I am using the org.apache.http.legacy.jar library, which requires this:

android{
   useLibrary 'org.apache.http.legacy'

   ...
}

So check that you have everything in your gradle file that is required.

Azurespot
  • 3,066
  • 3
  • 45
  • 73
1

I resolved the issue by double checking the "libs" directory and removing redundant jars, even though those jars were not manually added in the dependencies.

Hao Fu
  • 106
  • 4
1

see if their duplicate jars or dependencies your adding remove it and your error will be gone: Eg: if you add android:supportv4 jar and also dependency you will get the error so remove the jar error will be gone

haribabu
  • 31
  • 2
0

I resolve this is by changing the version no of recyleview to recyclerview-v7:24.2.1. Please check your dependencies and use the proper version number.

SUNIL JADHAV
  • 345
  • 3
  • 12
0

For me the issue was caused by com.google.android.exoplayer conflicting with com.facebook.android:audience-network-sdk.

I fixed the problem by excluding the exoplayer library from the audience-network-sdk :

compile ('com.facebook.android:audience-network-sdk:4.24.0') {
    exclude group: 'com.google.android.exoplayer'
}
Nika Kurdadze
  • 2,502
  • 4
  • 18
  • 28