eclipse:运行 Android 项目时出现 “Unable to execute dex: Multiple dex files define. Conversion to Dalvik format failed” 错误分析及解决方法 2014-11-17 / 7,337 次 / 快抢沙发 /

摘要:出现 “Unable to execute dex: Multiple dex files define. Conversion to Dalvik format failed” 类似的错误,一般都是因为编译的时候,出现多个 .jar 包的问题,我们可以尝试移除相关的 .jar 包,然后重新编译。

Runtime Environment
OS: Mac OS X 10.9.2
IDE: ADT Bundle v23.0.2
在使用 eclipse + ADT 开发 Android 项目开发的过程中,运行项目的时候,发现有以下错误:

[2014-11-17 19:01:24 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
[2014-11-17 19:01:24 - **********] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
从以上内容可以看出应该是 android-support-v4.jar 包冲突的原因。我们去到项目中的 bin/dexedLibs 文件夹下:
multi-android-support-v4-jar-in-android-project-dexedlibs-folder

我们可以看到在 bin/dexedLibs 文件夹下有两个 android-support-v4 的编译 .jar 包,由于我的项目中引入了一个 Actionbar Sherlock 的库工程,我猜测是这个库工程中的 android-support-v4.jar 和本工程中的 android-support-v4.jar 包冲突。我们右键点击项目,选择 Build Path → Configure Build Path → Order and Export :我们取消 android-support-v4.jar 前面的对勾。重新编译。问题解决!
remove-android-support-v4-jar-in-eclipse-java-build-path-order-and-export

通过 Git 我们可以看到工程的 .classpath 文件有以下变动:
android-project-classpath-file-classpathentry-exported-equals-true-removed

如果出现 “Unable to execute dex: Multiple dex files define. Conversion to Dalvik format failed” 类似的错误,一般都是因为编译的时候,出现多个 .jar 包的问题,我们可以尝试移除相关的 .jar 包,然后重新编译。
打赏
上一篇: « 下一篇: »
Copyright © ifeegoo Time is limited, less is more! / 粤ICP备15109713号 / Theme by Hang & Ben / WordPress / 知识共享许可协议