java - Android tests build error: Multiple dex files define Landroid/support/test/BuildConfig -
i'm trying add espresso 2 project (which has lots of other dependencies), i'm hitting error when trying run tests:
unexpected top-level exception: com.android.dex.dexexception: multiple dex files define landroid/support/test/buildconfig; @ com.android.dx.merge.dexmerger.readsortabletypes(dexmerger.java:596) @ com.android.dx.merge.dexmerger.getsortedtypes(dexmerger.java:554) @ com.android.dx.merge.dexmerger.mergeclassdefs(dexmerger.java:535) ... the non-test build works fine.
does have tips on best way debug this?
i've tried running ./gradlew -q :<my_project>:dependencies, can't see obvious problems (though don't know interpreting output):
<snip> androidtestcompile - classpath compiling androidtest sources. +--- com.squareup.spoon:spoon-client:1.1.2 +--- com.google.dexmaker:dexmaker-mockito:1.0 | +--- com.google.dexmaker:dexmaker:1.0 | \--- org.mockito:mockito-core:1.9.5 | +--- org.hamcrest:hamcrest-core:1.1 | \--- org.objenesis:objenesis:1.0 +--- com.google.dexmaker:dexmaker:1.0 +--- org.mockito:mockito-core:1.9.5 (*) +--- com.jayway.android.robotium:robotium-solo:5.3.1 +--- com.android.support.test.espresso:espresso-core:2.0 | +--- com.squareup:javawriter:2.1.1 | +--- org.hamcrest:hamcrest-integration:1.1 | | \--- org.hamcrest:hamcrest-core:1.1 | +--- org.hamcrest:hamcrest-library:1.1 | | \--- org.hamcrest:hamcrest-core:1.1 | +--- javax.inject:javax.inject:1 | +--- com.android.support.test.espresso:espresso-idling-resource:2.0 | +--- com.android.support.test:testing-support-lib:0.1 | | \--- junit:junit-dep:4.10 | | \--- org.hamcrest:hamcrest-core:1.1 | +--- com.google.code.findbugs:jsr305:2.0.1 | +--- javax.annotation:javax.annotation-api:1.2 | \--- org.hamcrest:hamcrest-core:1.1 \--- com.android.support.test:runner:0.2 +--- junit:junit-dep:4.10 (*) +--- com.android.support.test:exposed-instrumentation-api-publish:0.2 \--- com.android.support:support-annotations:22.0.0 <snip> compile - classpath compiling main sources. +--- com.android.support:appcompat-v7:22.1.0 | \--- com.android.support:support-v4:22.1.0 | \--- com.android.support:support-annotations:22.1.0 +--- com.android.support:support-v4:22.1.0 (*) +--- com.afollestad:material-dialogs:0.7.2.4 | +--- com.android.support:support-v4:22.0.0 -> 22.1.0 (*) | +--- com.android.support:appcompat-v7:22.0.0 -> 22.1.0 (*) | +--- com.android.support:support-annotations:22.0.0 -> 22.1.0 | \--- com.android.support:recyclerview-v7:22.0.0 | +--- com.android.support:support-v4:22.0.0 -> 22.1.0 (*) | \--- com.android.support:support-annotations:22.0.0 -> 22.1.0 +--- com.google.android.gms:play-services-base:7.0.0 | \--- com.android.support:support-v4:22.0.0 -> 22.1.0 (*) +--- com.google.android.gms:play-services-gcm:7.0.0 | \--- com.google.android.gms:play-services-base:7.0.0 (*) +--- de.greenrobot:greendao:1.3.7 +--- de.greenrobot:eventbus:2.2.0 +--- com.squareup.wire:wire-runtime:1.4.0 | \--- com.squareup.okio:okio:0.6.0 -> 1.0.1 +--- com.squareup.okio:okio:1.0.1 +--- com.squareup.okhttp:okhttp-urlconnection:2.0.0 | \--- com.squareup.okhttp:okhttp:2.0.0 | \--- com.squareup.okio:okio:1.0.0 -> 1.0.1 +--- com.squareup.retrofit:retrofit:1.6.0 | \--- com.google.code.gson:gson:2.2.4 +--- com.squareup.retrofit:converter-wire:1.6.0 | +--- com.squareup.retrofit:retrofit:1.6.0 (*) | \--- com.squareup.wire:wire-runtime:1.2.0 -> 1.4.0 (*) +--- com.squareup.okhttp:okhttp:2.0.0 (*) +--- com.squareup.picasso:picasso:2.4.0 +--- com.path:android-priority-jobqueue:1.1.2 | \--- com.google.android:android:2.2.1 | +--- commons-logging:commons-logging:1.1.1 | +--- org.apache.httpcomponents:httpclient:4.0.1 | | +--- org.apache.httpcomponents:httpcore:4.0.1 | | +--- commons-logging:commons-logging:1.1.1 | | \--- commons-codec:commons-codec:1.3 | +--- org.khronos:opengl-api:gl1.1-android-2.1_r1 | +--- xerces:xmlparserapis:2.6.2 | +--- xpp3:xpp3:1.1.4c | \--- org.json:json:20080701 +--- com.netflix.rxjava:rxjava-android:0.16.1 | \--- com.netflix.rxjava:rxjava-core:0.16.1 +--- com.nineoldandroids:library:2.4.0 +--- it.sephiroth.android.library.horizontallistview:hlistview:1.2.2 | \--- com.android.support:support-v4:19.1.+ -> 22.1.0 (*) +--- com.joooonho:selectableroundedimageview:1.0.1 +--- com.crashlytics.sdk.android:crashlytics:2.0.1 | +--- com.crashlytics.sdk.android:answers:1.0.1 | | \--- io.fabric.sdk.android:fabric:1.0.1 | +--- io.fabric.sdk.android:fabric:1.0.1 | \--- com.crashlytics.sdk.android:beta:1.0.1 | \--- io.fabric.sdk.android:fabric:1.0.1 +--- com.mixpanel.android:mixpanel-android:4.5.3 \--- com.facebook.android:facebook-android-sdk:4.0.0 +--- com.android.support:support-v4:[21,22) -> 22.1.0 (*) \--- com.parse.bolts:bolts-android:1.1.4 <snip> i've tried searching subfolders of build/intermediates directory, couldn't see smoking guns (though i'm not sure searching external dependency jars in right way).
here dependency section of build.gradle:
dependencies { compile 'com.android.support:appcompat-v7:22.1.0' compile 'com.android.support:support-v4:22.1.0' compile 'com.afollestad:material-dialogs:0.7.2.4' compile 'com.google.android.gms:play-services-base:7.0.0' compile 'com.google.android.gms:play-services-gcm:7.0.0' compile 'de.greenrobot:greendao:1.3.7' compile 'de.greenrobot:eventbus:2.2.0' compile 'com.squareup.wire:wire-runtime:1.4.0' compile 'com.squareup.okio:okio:1.0.1' compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0' compile 'com.squareup.retrofit:retrofit:1.6.0' compile 'com.squareup.retrofit:converter-wire:1.6.0' compile 'com.squareup.okhttp:okhttp:2.0.0' compile 'com.squareup.picasso:picasso:2.4.0' compile 'com.path:android-priority-jobqueue:1.1.2' compile 'com.netflix.rxjava:rxjava-android:0.16.1' compile 'com.nineoldandroids:library:2.4.0' compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2' compile 'com.joooonho:selectableroundedimageview:1.0.1' compile('com.crashlytics.sdk.android:crashlytics:2.0.1@aar') { transitive = true; } compile "com.mixpanel.android:mixpanel-android:4.5.3" compile "com.facebook.android:facebook-android-sdk:4.0.0" // rollbar jar, not available in maven central compile filetree(dir: 'libs', include: '*.jar') androidtestcompile 'com.squareup.spoon:spoon-client:1.1.2' androidtestcompile 'com.google.dexmaker:dexmaker-mockito:1.0' androidtestcompile 'com.google.dexmaker:dexmaker:1.0' androidtestcompile 'org.mockito:mockito-core:1.9.5' androidtestcompile 'com.jayway.android.robotium:robotium-solo:5.3.1' androidtestcompile 'com.android.support.test.espresso:espresso-core:2.0' androidtestcompile 'com.android.support.test:runner:0.2' } update: when update com.android.tools.build:gradle:1.0.0 com.android.tools.build:gradle:1.1.1, warning:
warning:conflict dependency 'com.android.support:support-annotations'. resolved versions app (22.1.0) , test app (22.0.0) differ.
update (9/07/2015):
you can continue work 22.2.1 if use following excludes:
androidtestcompile ('com.android.support.test.espresso:espresso-core:2.2') { exclude group: 'com.android.support', module: 'support-annotations' } androidtestcompile ('com.android.support.test:runner:0.3') { exclude group: 'com.android.support', module: 'support-annotations' } androidtestcompile ('com.android.support.test:rules:0.3') { exclude group: 'com.android.support', module: 'support-annotations' } if depend on espresso-contrib, need exclude well.
update (8/03/2015):
with support library 22.2.1, dependencies broken again; please don't upgrade 22.2.1 until new runner released.
update (6/04/2015):
with latest release of runner 0.3 , rules 0.3, answer no longer needed. can use
androidtestcompile 'com.android.support.test:runner:0.3' androidtestcompile 'com.android.support.test:rules:0.3' androidtestcompile 'com.android.support.test.espresso:espresso-core:2.2' with latest support libraries. (22.2.0 of writing)
update (5/30/2015):
compile 'com.android.support:appcompat-v7:22.2.0' androidtestcompile 'com.android.support.test.espresso:espresso-core:2.2' // com.android.support.test:testing-support-lib:0.1 // <-- causes issue update (4/24/2015):
the problem com.android.support:support-v4:22.1.1 clashing com.android.support.test:runner:0.2 (as depends on com.android.support:support-v4:22.0.0).
com.android.support.test.espresso:espresso-core:2.1 has dependency on com.android.support.test:runner:0.2, causes same error.
so, combination work:
compile 'com.android.support:support-v4:22.0.0' androidtestcompile 'com.android.support.test.espresso:espresso-core:2.1' ...and 1 (without 'com.android.support.test:runner:0.2'):
compile 'com.android.support:support-v4:22.1.0' androidtestcompile 'com.android.support.test.espresso:espresso-core:2.0' original answer:
contrary what espresso documentation says, should remove dependency:
androidtestcompile 'com.android.support.test:runner:0.2'
as cause library version conflict.
you should update android gradle plugin 1.1.1, version tell exact version conflict, useful in case.
Comments
Post a Comment