2

在我的项目中,使用库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 库的 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')
}. 

如果我删除依赖,我会得到其他错误。我能做些什么?

4

1 回答 1

2

似乎您在项目中和项目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 支持库也做同样的事情。它应该只声明一次,否则你会得到类似的错误。

于 2015-01-13T00:33:48.130 回答