This question already has answers here:
Android tests build error: Multiple dex files define Landroid/support/test/BuildConfig
(7 个回答)
5年前关闭。
在尝试迁移到 espresso 2.1 时,我遇到了以下障碍
但我只看到一个来源:
关于如何解决这个问题的任何提示?这是依赖树:
但它根本不起作用。
(7 个回答)
5年前关闭。
在尝试迁移到 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
最佳答案
小世界 ;)
这个 DexException of Multiple dex files 是由 espresso-contrib:2.1 间接引起的,真正的根本原因是 com.android.support.test:runner:0.2 ,它有一些其他的子依赖。
删除 test:runner 对我有用。
虽然还有另一个 post 说这是因为 com.android.support:support-v4 ,在你的情况下,它是 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'
}
但它根本不起作用。
关于android - 多个dex文件定义Landroid/support/test/espresso/contrib/DrawerActions,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29945930/