I moved my Android IntelliJ IDEA project from one location to another. For some reason, IDEA lost all the modules and I had to re-import them.
Now when I compile, I get this DEX error:
Error:Android Dex: [MyApp] Unable to execute DX
Error:Android Dex: [MyApp] com.android.dex.DexException: Multiple dex files define Lcom/google/common/base/FinalizableReference;
Error:Android Dex: [MyApp] at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
Error:Android Dex: [MyApp] at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
Error:Android Dex: [MyApp] at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
Error:Android Dex: [MyApp] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
Error:Android Dex: [MyApp] at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
Error:Android Dex: [MyApp] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
Error:Android Dex: [MyApp] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
Error:Android Dex: [MyApp] at com.android.dx.command.dexer.Main.run(Main.java:230)
Error:Android Dex: [MyApp] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:Android Dex: [MyApp] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Error:Android Dex: [MyApp] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Error:Android Dex: [MyApp] at java.lang.reflect.Method.invoke(Method.java:597)
Error:Android Dex: [MyApp] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:161)
Error:Android Dex: [MyApp] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:294)
Error:Android Dex: [MyApp] at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)
I can't figure out what the cause is, all the usual suspects of multiple JARs seems to be ok.
Is there a way to turn on verbose logging to get a better understanding on which libs are in conflict?
I don't know how to get better error description from DEX, but here are 2 suggestions to troubleshoot:
If using Android Studio, just search for the offending class FinalizableReference
(include non-project classes in the search).
(Use Command+N
for find class or double tap Shift
for "search everywhere".
For eclipse: Ctrl+Shift+T
? others can confirm.
Using the command line: jar tf mylib.jar | grep FinalizableReference
will search mylib for the class. You can then use some shell for
loop over the jar files (usually in libs dir).
Also grep -r FinalizableReference libs/*\.jar
will scan all the jars (assuming you have them in libs) and notify the ones that have a match (the duplicates).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With