多个dex文件定义了Landroid / support / test / espresso / contrib / DrawerActions

时间:2015-04-29 13:57:03

标签: android android-espresso

尝试迁移到espresso 2.1时,我点击了以下路障

com.android.dex.DexException: Multiple dex files define Landroid/support/test/espresso/contrib/DrawerActions$1;
    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)

但我只看到一个来源:

 androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.1'

有关如何解决此问题的任何提示?这是依赖树:

androidTestCompile - Classpath for compiling the androidTest sources.
+--- com.android.support.test:runner:0.2
|    +--- junit:junit-dep:4.10
|    |    \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
|    +--- com.android.support.test:exposed-instrumentation-api-publish:0.2
|    \--- com.android.support:support-annotations:22.0.0
+--- com.android.support.test:rules:0.2
|    \--- com.android.support.test:runner:0.2 (*)
+--- com.android.support.test.espresso:espresso-contrib:2.1
|    +--- com.android.support:recyclerview-v7:22.0.0
|    |    +--- com.android.support:support-v4:22.0.0
|    |    |    \--- com.android.support:support-annotations:22.0.0
|    |    \--- com.android.support:support-annotations:22.0.0
|    +--- com.android.support:support-v4:22.0.0 (*)
|    \--- com.android.support.test.espresso:espresso-core:2.1
|         +--- com.android.support.test:rules:0.2 (*)
|         +--- com.squareup:javawriter:2.1.1
|         +--- org.hamcrest:hamcrest-integration:1.1
|         |    \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
|         +--- com.android.support.test.espresso:espresso-idling-resource:2.1
|         +--- org.hamcrest:hamcrest-library:1.1
|         |    \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
|         +--- javax.inject:javax.inject:1
|         +--- com.google.code.findbugs:jsr305:2.0.1
|         +--- com.android.support.test:runner:0.2 (*)
|         +--- javax.annotation:javax.annotation-api:1.2
|         \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
+--- info.cukes:cucumber-java:1.2.0
|    \--- info.cukes:cucumber-core:1.2.0
|         +--- info.cukes:cucumber-html:0.2.3
|         +--- info.cukes:cucumber-jvm-deps:1.0.3
|         \--- info.cukes:gherkin:2.12.2
+--- info.cukes:cucumber-android:1.2.0
+--- com.google.dexmaker:dexmaker-mockito:1.0
|    \--- org.mockito:mockito-core:1.9.5
|         \--- org.objenesis:objenesis:1.0
+--- org.assertj:assertj-core:1.7.1-TARGETFIX
+--- com.uphyca:android-junit4:0.5
\--- junit:junit:4.11
     \--- org.hamcrest:hamcrest-core:1.3

1 个答案:

答案 0 :(得分:0)

小世界;)

多个dex文件的DexException是由 espresso-contrib:2.1 间接引起的,真正的根本原因是 com.android.support。 test:runner:0.2 ,它有一些其他的子依赖项。

删除 test:runner 对我有用。

虽然有另一个post因为 com.android.support:support-v4 而说出来,但在你的情况下,它&# 39; s 22.0.0 进行测试,也许您的应用模块使用的是不同的版本。所以我试着这样做:

androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.1') {
    exclude group: 'com.android.support', module: 'support-v4'
    exclude module: 'support-annotations'
}

但它根本不起作用。