3

I ported an Eclipse project to Android Studio IDE, the project was using android-support-v4, android-support-v13 and appcompat_v7 libraries, everything was fine but when I used Android Studio I got the following error each time I tried to run the project:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v13/app/FragmentCompatICS;
    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:302)
    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)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2
Information:BUILD FAILED

Note: it works once I cleaned the project, then the same error happened again next run, so I have to clean each time I run.

Anyone have any idea why this keep happenning?

Hazem Hagrass
  • 9,329
  • 10
  • 32
  • 54

1 Answers1

0

First please refer to this answer in figuring out why it occurs and fixing it as it suggests.

And in case anyone finds out that that answer could not be applied to android library project, here is the snippet to fix

compile (project(':yourAndroidLibrary')){ exclude module: 'support-v13' }


You will find problems

Unsupported Gradle DSL method found: 'exclude()'

if you use compile project(':yourAndroidLibrary'){ exclude module: 'support-v13' }

The differences are the bracelet "(" and ")" before "project".

Community
  • 1
  • 1
Tony Thompson
  • 410
  • 5
  • 13