Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple dex files define landroid/support/annotation/AnimRes

Tags:

java

android

The moment I added the android support annotations to my dependencies

compile 'com.android.support:support-annotations:20.0.0'

I got this error:

Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287) at com.android.dx.command.dexer.Main.run(Main.java:230) at com.android.dx.command.dexer.Main.main(Main.java:199) at com.android.dx.command.Main.main(Main.java:103)

build.gradle

android {
    compileSdkVersion 19
    buildToolsVersion '20.0.0'

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 19
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.0.0'
    compile 'com.crashlytics.android:crashlytics:1.+'
    compile 'com.android.support:support-annotations:20.0.0'
}

Anybody else experienced this issue? I have tried the solutions from here.

like image 914
Niklas Avatar asked Oct 13 '14 14:10

Niklas


3 Answers

The problem is that android-support-annotations.jar used to be a separate library containing the android annotations, but for some reason these annotations are already included in recent versions of the android-support-v4.jar file.

Deleting the annotations jar solved the issue.

like image 127
Mister Smith Avatar answered Nov 04 '22 00:11

Mister Smith


Build->clean Project ,and it worked

like image 34
user2955733 Avatar answered Nov 03 '22 22:11

user2955733


I deleted the android-support-v4.jar and it worked.

like image 23
Evans Kakpovi Avatar answered Nov 03 '22 22:11

Evans Kakpovi