我正在尝试在整合twitter4j jar依赖项后运行我的应用程序而且我遇到了麻烦。
这是我的gradle文件:
dependencies {
compile 'com.squareup.retrofit:retrofit:1.5.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.nhaarman.listviewanimations:library:2.6.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'ch.acra:acra:4.5.0'
compile 'de.psdev.licensesdialog:licensesdialog:1.4.0'
compile (group: 'org.twitter4j', name: 'twitter4j-core', version: '4.0.1') {
exclude group: 'com.google.android', module: 'support-v7'
}
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
正如你所看到我正在导入twitter4j,但我遇到了依赖关系的麻烦。
这是gradle控制台的输出,在此行之后:
C:...路径... \构建\中间体\预dexed \调试\ twitter4j核-4.0.1-cba1ebcdb3cdaa1deeed0e45ec882496572212ad.jar
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
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)
我尝试排除支持lib,我尝试将jar dircetly导入libs文件夹,但我总是遇到这个问题。
任何人都面临这个问题或任何想法我该如何解决?
谢谢。
答案 0 :(得分:1)
我依次为每个依赖项添加了support-v4库的排除,直到找到了有问题的依赖项。这似乎是错误的包装。改变这一行:
compile 'de.psdev.licensesdialog:licensesdialog:1.4.0'
到此:
compile ('de.psdev.licensesdialog:licensesdialog:1.4.0') {
exclude group: 'com.google.android', module: 'support-v4'
}