Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException

I am trying to integrate barcodefraglibv2 into my android app in AndroidStudio. I tried to copy libs core.jar and barcodelib.jar into libs directory. However when I try to run application, I get following error

Error:Execution failed for task ':Blok:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /home/backman/android/sdk/build-tools/android-4.4.2/dx --dex --output /home/backman/AndroidStudioProjects/Blok/Blok/build/dex/debug /home/backman/AndroidStudioProjects/Blok/Blok/build/classes/debug /home/backman/AndroidStudioProjects/Blok/Blok/build/dependency-cache/debug /home/backman/AndroidStudioProjects/Blok/Blok/build/pre-dexed/debug/core-bcdbe5f84dd399255abb34d14ce9def109db2534.jar
  Error Code:
    2
  Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/BarcodeFormat;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
        at com.android.dx.command.dexer.Main.run(Main.java:230)
        at com.android.dx.command.dexer.Main.main(Main.java:199)
        at com.android.dx.command.Main.main(Main.java:103)

I have no luck trying to solve it.

like image 395
pfulop Avatar asked Apr 16 '14 17:04

pfulop


3 Answers

You have multiple copies of the classes in zxing in your app. You should likely have exactly one copy: the core .jar in libs/ and nothing else.

like image 58
Sean Owen Avatar answered Nov 07 '22 22:11

Sean Owen


Solved,

I removed libraries, reload project, add libraries, removed my references to support-v4, removed libraries again, build, add libraries, build, added back references and build.

like image 21
pfulop Avatar answered Nov 07 '22 22:11

pfulop


I removed from /libs folder and cleaned and rebuild it again.problem fixed

GoogleAdMobAdsSdk-6.4.1
android-support-v4
like image 2
Mendim Avatar answered Nov 07 '22 23:11

Mendim