cleardo / android-test-kit

Automatically exported from code.google.com/p/android-test-kit
0 stars 0 forks source link

DexException Multiple dex files define Ljunit/extenstions/ActiveTestSuite$1; #119

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Added Espresso 2.0 to the project build.gradle
2. Created a test case (A junit4 based test)
3. Try and run the test runner.

What is the expected output? What do you see instead?

xecution failed for task ':justyoyo:dexJustyoyoDevDebugTest'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Developer/android-sdk-macosx/build-tools/21.1.2/dx --dex --no-optimize --output /Users/chris/Git/Yoyo-Android/justyoyo/build/intermediates/dex/test/justyoyodev/debug --input-list=/Users/chris/Git/Yoyo-Android/justyoyo/build/intermediates/tmp/dex/test/justyoyodev/debug/inputList.txt
  Error Code:
    2
  Output:

    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Ljunit/extensions/ActiveTestSuite$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)

What version of the product are you using? On what operating system?

Target v21, BuildTools 21.1.2, OSx 10.10, Gradle 2.2. 

Please provide any additional information below.

I also have Robolectric enabled. Would this cause a confliction?

Original issue reported on code.google.com by chris.mark.jenkins@gmail.com on 15 Jan 2015 at 12:32

GoogleCodeExporter commented 9 years ago
at least have the same issue :(

Original comment by to.mikek...@gmail.com on 5 Feb 2015 at 3:51

GoogleCodeExporter commented 9 years ago
dexOptions {
     preDexLibraries false
}
May help you as a temporary workaround

Original comment by imor...@gmail.com on 11 Feb 2015 at 1:10

GoogleCodeExporter commented 9 years ago
thanks for the feedback, for me: fixed one: came up another:
 Error Code:
    3
  Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: already added: Lorg/hamcrest/BaseDescription;
        at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
        at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
        at com.android.dx.command.dexer.Main.processClass(Main.java:732)
        at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
        at com.android.dx.command.dexer.Main.access$300(Main.java:82)
        at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
        at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
        at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
        at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
        at com.android.dx.command.dexer.Main.processOne(Main.java:632)
        at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:279)
        at com.android.dx.command.dexer.Main.run(Main.java:245)
        at com.android.dx.command.dexer.Main.main(Main.java:214)
        at com.android.dx.command.Main.main(Main.java:106)

Original comment by to.mikek...@gmail.com on 11 Feb 2015 at 2:01

GoogleCodeExporter commented 9 years ago
Unfortunately, I also stumbled on this Issue.

Windows 8.1 Pro 64bit
java version "1.7.0_67"
Gradle 2.2.1
android-sdk 24.0.2
BuildTools 21.1.2
android-gradle-plugin 1.1.1

There are my open source projects that can be reproduced here.
https://github.com/jakenjarvis/Android-OrmLiteContentProvider/tree/develop

Reproduced in the following procedure.
> git clone -b develop 
git@github.com:jakenjarvis/Android-OrmLiteContentProvider.git
> cd Android-OrmLiteContentProvider
> git checkout -b a37feee
> git submodule update --init
> cd gradle
> cd commonlibrary
> git checkout -b c9dcc43
> cd ..
> cd ..
> gradlew clean build test connectedAndroidTest

Original comment by Jaken.Jarvis on 26 Feb 2015 at 12:59

GoogleCodeExporter commented 9 years ago
Doesn't look like an espresso issue. You need to sort out why that file gets 
included in multiple dex files.

Original comment by vale...@google.com on 18 Mar 2015 at 5:24

GoogleCodeExporter commented 9 years ago
I encountered this issue and it seems that it was because i included 

androidTestCompile 'com.google.truth:truth:0.25'

I didn't quite realise that truth pulls in guava (among others deps that caused 
conflicts as above). 
My solution was to remove this lib but you can trace the conflicts using 
./gradlew -q mobile:dependencies

Original comment by d.w.flan...@googlemail.com on 23 Apr 2015 at 12:24