com.android.dex.DexException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Impacted Cases ============== In an Android project that uses Gradle, it becomes a nuisance mixing Xwalk with other libraries that uses the JSR305 dependency. The compilation fails and the developer must learn about how to workaround the dependency problem. In my case, I detected this case because I used Facebook's Stetho that depends on JSR305: ./gradlew :app:dependencies +--- com.facebook.stetho:stetho:1.3.1 | +--- com.google.code.findbugs:jsr305:2.0.1 | \--- commons-cli:commons-cli:1.2 Reproduce Test Steps ==================== 1. Add the Xwalk dependency to your build.gradle file following the official instructions. 2. Add a library that uses the JSR305 artifact to your build.gradle, like Facebook's Stetho. Add this line into the dependencies block: compile 'com.facebook.stetho:stetho:1.3.1' 3. Try to compile your project: ./gradlew clean assembleX86Debug Expected Outcome ================ BUILD SUCCESSFUL Actual Outcome ============== BUILD FAILED , because of this exception: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Ljavax/annotation/CheckForNull; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106) Test Case Source Code ===================== There's a project attached to check the issue. Check the app/build.gradle file. In the dependencies block, it contains what the user is going to do and in a comment, the current workaround to make possible the compilation. Please, notice that this could happen with another jar that embeds the JS305 dependency like XWalk currently, making impossible to use this workaround. The workaround involves excluding the JSR305 dependency like this: compile ('com.facebook.stetho:stetho:1.3.1') { exclude module: 'jsr305'; }
    via by Tomás GP,
  • GitHub comment 62#206876390
    via GitHub by benas
    ,
  • Impacted Cases ============== In an Android project that uses Gradle, it becomes a nuisance mixing Xwalk with other libraries that uses the JSR305 dependency. The compilation fails and the developer must learn about how to workaround the dependency problem. In my case, I detected this case because I used Facebook's Stetho that depends on JSR305: ./gradlew :app:dependencies +--- com.facebook.stetho:stetho:1.3.1 | +--- com.google.code.findbugs:jsr305:2.0.1 | \--- commons-cli:commons-cli:1.2 Reproduce Test Steps ==================== 1. Add the Xwalk dependency to your build.gradle file following the official instructions. 2. Add a library that uses the JSR305 artifact to your build.gradle, like Facebook's Stetho. Add this line into the dependencies block: compile 'com.facebook.stetho:stetho:1.3.1' 3. Try to compile your project: ./gradlew clean assembleX86Debug Expected Outcome ================ BUILD SUCCESSFUL Actual Outcome ============== BUILD FAILED , because of this exception: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Ljavax/annotation/CheckForNull; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106) Test Case Source Code ===================== There's a project attached to check the issue. Check the app/build.gradle file. In the dependencies block, it contains what the user is going to do and in a comment, the current workaround to make possible the compilation. Please, notice that this could happen with another jar that embeds the JS305 dependency like XWalk currently, making impossible to use this workaround. The workaround involves excluding the JSR305 dependency like this: compile ('com.facebook.stetho:stetho:1.3.1') { exclude module: 'jsr305'; }
    via by Tomás GP,
  • DexException: Multiple dex files
    via Stack Overflow by Liquid Ink
    ,
  • DexException: Multiple dex files
    via by Unknown author,
  • DexException: Multiple dex files
    via by Unknown author,
    • com.android.dex.DexException: Multiple dex files define Ljavax/annotation/CheckForNull; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106)

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    50 more bugmates