在我的项目中,使用库MaterialDesign。当我添加库MPchart时,我收到此错误并且不明白什么是错的。谢谢
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
MaterialDesign Library的build.gradle:
dependencies {
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.android.support:support-v4:21.0.3'
}
和build.gradle项目:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.nineoldandroids:library:2.4.+'
compile project(":MaterialDesign")
compile project(":MPChartLib")
compile files('libs/opencsv-2.4.jar')
}.
如果我删除了依赖性,我会得到其他错误。 我该怎么办?
答案 0 :(得分:1)
您似乎在com.nineoldandroids:library:2.4.+
和项目中都声明了依赖项MPChartLib
。这就是造成这个问题的原因。
尝试从项目中删除依赖项,但将其保留在MPChartLib中,以便dextool只能看到它一次。您的新build.gradle将如下所示:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile project(":MaterialDesign")
compile project(":MPChartLib")
compile files('libs/opencsv-2.4.jar')
}
对Android支持库也这样做。它应该只声明一次,否则你会得到类似的错误。