从eclipse导入到Android Studio时,多个dex文件定义异常

时间:2014-12-14 20:59:57

标签: android android-studio

我刚刚将包含所有依赖项的项目导入Android Studio。编译后我看到了这个错误

Error:Android Dex: [APPA] Unable to execute DX
Error:Android Dex: [APPA] com.android.dex.DexException: Multiple dex files define Lcom/android/volley/VolleyError;
Error:Android Dex: [APPA] at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
Error:Android Dex: [APPA] at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
Error:Android Dex: [APPA] at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
Error:Android Dex: [APPA] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Error:Android Dex: [APPA] at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
Error:Android Dex: [APPA] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
Error:Android Dex: [APPA] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
Error:Android Dex: [APPA] at com.android.dx.command.dexer.Main.run(Main.java:246)
Error:Android Dex: [APPA] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:Android Dex: [APPA] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Error:Android Dex: [APPA] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Error:Android Dex: [APPA] at java.lang.reflect.Method.invoke(Method.java:597)
Error:Android Dex: [APPA] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:161)
Error:Android Dex: [APPA] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:294)
Error:Android Dex: [APPA] at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)

1 个答案:

答案 0 :(得分:1)

问题是库在项目的依赖项中是重复的。我没有使用gradle,所以我无法检查其他答案中最常见的命令。所以我修复它打开模块设置,逐个检查所有依赖项,然后删除重复项。此外,我首先在Eclipse中打开它并将其作为gradle项目导出然后在Android工作室中将其打开,我将项目切换为gradle。