Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: "duplicate entry: android/support/v7/appcompat/R$anim.class"

Building an app generates the following error:

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

I have cleaned and built the project many times to no avail. It has the following in its gradle build:

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

It also uses a library via its aar file. That library project also has the above in its gradle build.

Could anyone offer a tip on how to resolve this?

like image 628
Hong Avatar asked Apr 19 '16 19:04

Hong


1 Answers

Yup , Face same problem few days ago

Reason - as you told "That library project also has the above in its gradle build" actually system wont able to understand which dependency hi will take (app's - compile 'com.android.support:appcompat-v7:23.3.0' or module project's - compile 'com.android.support:appcompat-v7:23.3.0' ) so that hi says you have duplicate entry

How To Resolve -

Step 1 - Just Clean/Build Project. go to Build -> Clean/Build Project.

Step 2 - In terminal execute in root project folder ./gradlew clean*

Step 3- you have to exclude your group from one dependency

compile('com.android.support:design:23.2.1') {
    exclude group: 'com.android.support', module: 'support-v7'
}

Step 4 - Check Out This Awsome Answer https://stackoverflow.com/a/19022328/4741746

And Answer That Work for me is -

I just remove 1 dependency from apps level gradle and just put only in module project level gradle and also exclude support-v4 in which that anim class exist

  compile 'com.android.support:appcompat-v7:23.2.1'
        compile('com.android.support:design:23.2.1') {
            exclude group: 'com.android.support', module: 'support-v4'
        }
like image 114
sushant gosavi Avatar answered Nov 03 '22 10:11

sushant gosavi