4

when trying to migrate to espresso 2.1 I hit the following road-block

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)

but I only see one source for this:

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

any hint on how to solve this? This is the dependency tree:

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
ligi
  • 39,001
  • 44
  • 144
  • 244

1 Answers1

0

small world ;)

This DexException of Multiple dex files are caused indirectly by espresso-contrib:2.1, the real root cause is com.android.support.test:runner:0.2, which has some other sub-dependencies.

Removing test:runner works for me.

While there is another post saying it's because of com.android.support:support-v4, in your case, it's 22.0.0 for the test, and maybe your app module is using different version. So I tried to do:

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

but it doesn't work at all.

Community
  • 1
  • 1
Jing Li
  • 14,547
  • 7
  • 57
  • 69
  • 1
    so your answer is something that actually does not work... – Ovidiu Latcu May 14 '15 at 09:33
  • 1
    @OvidiuLatcu I'm just trying to analyze the problem, write down the clues and what is working or not. Even if it doesn't work, it might still be helpful. – Jing Li May 14 '15 at 09:53
  • @JingLi What? That is a terrible reason. – Jared Burrows May 31 '15 at 02:00
  • Sorry @JaredBurrows, but what is a terrible reason? – Jing Li May 31 '15 at 14:02
  • Please keep comments to a minimum on StackOverflow. You want to add answers that are related to the question, which you did. I said it was a "terrible reason" because you said "Even if it doesn't work, it might still be helpful." which means you didn't even try **your own answer**. – Jared Burrows May 31 '15 at 14:28
  • 1
    Please read my original answer, I said "but it doesn't work at all.", why did you say "I didn't even try my own answer"? – Jing Li May 31 '15 at 14:31