Unable to execute dex: Multiple dex files define

我知道这个问题以前在这里被问过几次。但我还没看到任何可能的解决方案。 在我做这个项目“运行 Android 应用程序”之前,如果我没有清理它,我会收到下面的错误,必须重新启动 Eclipse... 然后再清理一次。

Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define
Lcom/jstun/core/attribute/MessageAttributeInterface;

Core... 是我的 src 文件夹的一部分,当然我不能删除它。即使我删除了这个包,另一个包也会显示错误,比如:

Unable to execute dex: Multiple dex files define
Landroid/support/v4/app/ActivityCompatHoneycomb;

自从更新到 ADT 15以来,我已经看到了这个错误,我正在 Ubuntu 上使用 Eclipse Galileo 你有什么想法吗? 谢谢你的回复!

193250 次浏览

这是一个构建路径问题。

  • 确保生成路径中没有包含 bin 文件夹。

  • 右键单击您的项目-> 转到属性-> 构建路径。

  • Make sure that Honeycomb library is in your libs/ folder and not in your source folder.

  • 在构建路径中分别包含 libs/中的库。

    BTW, you may want to bring in the android-support-v4 library to get Ice Cream Sandwich support instead of the Honeycomb support library.

我今天遇到了一个类似的错误,原因是支持库被我的应用程序项目使用的两个库项目引用,但是版本不同。

更多细节: 我的应用程序依赖于两个图书馆项目

  • FaceBookSDK 3.0-> ,它引用了 android-support-v4
  • ActionBarSherlock-> ,它引用了 android-support-v4,但是修改了版本以支持映射。

为了解决这个问题,我不得不使 FaceBookSDK 库直接依赖于 ABS 库而不是支持库。

修改 Eclipse ini中的最大内存参数

-Xmx1024m

And restart your computer.

这对我很有效:)

我把这个答案留给像我一样陷入这种境地的人。

在注意到我错误地将 Support Library JAR 文件拖放到我的 src 文件夹中之前,我在这里和那里跌跌撞撞。因为我不知道它是怎么发生的,也不知道什么时候掉在那里的,所以我从来没有想过那里有什么不对劲的地方。

我得到了同样的错误,我发现问题后,一段时间,并删除了它。项目现在运行良好。

如果你们中的一些人面临这个问题,Facebook-内容-插件的电话差距

尝试删除 bin/class/com/facebook/android 目录中的文件!-> 并重建

我在我的项目中也遇到过这个问题。 AVD 不能重新加载资产、 lib、 res 等文件夹上下文。 问题: Dex Loader ]无法执行 Dex: 多个 Dex 文件定义 Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl

Then,I created new projects and copied MainActivity.java,activity_main.xml, drawable context. 然后从包探索中删除旧项目,重新启动 Eclipse 和 AVD。 My project is now working properly.... :) 我希望这些步骤能帮助你们这些小家伙... ! !

This error happened to me when in my app's project I referenced a Library project in my Eclipse workspace (in my case the Facebook SDK) 同时 included the Facebook SDK as a jar in the libs folder. Removing the library reference but keeping the jar in the libs folder removed the error.

对我来说,解决方法就是做以下几件事:

  1. - > 项目中的 lib 目录,并删除任何多个元素。
  2. 项目-> 属性-> Java 构建路径和删除任何依赖库是自动添加的,而不是由您!-> 应用
  3. 重新启动 Eclipse IDE
  4. 现在清理项目。
  5. Run/Debug on Device/Emulator the project ... 祝你好运

对我来说,我删除了名为 android support v4.jar 的 libs 文件夹中的文件,一切都解决了。祝你好运

我得到这个错误的另一个原因。我错误地同时添加了 v4和 v13支持库。这对我来说是没有必要的,因为我的 minSdkVersion 是15。

我修复了它的 只有包括13版本的支持库。另外,请确保在 eclipse 中检查导出的库构建路径中的库标记。我还把它移到了顶部。

正如其他人提到的,当您在构建路径中或在设置中的其他地方有同一个类的多个副本时,就会发生这种情况。

我已经将 android-support-v4.jar 添加到我的 libs/文件夹中,然后 eclipse 以某种方式将第二个副本添加到 bin/classes/android-support-v4.jar 中。

你可以用

类名 YourApp | grep jar

删除 bin/class 中的额外副本解决了这个问题——不知道 Eclipse 为什么要在那里制作副本。

我也有同样的问题,我尝试的是:

  1. 列表项目
  2. 打开项目生成路径,
  3. 选择“图书馆”标签,
  4. 删除除 Android 库之外的所有库
  5. Adding all required JARs Files,
  6. 搞定!

我没问题,谢谢。

即使我回答了很多问题,也没有解决的办法。

我从构建路径中删除了“ Android 依赖项”。 Added all the jar files again to the build path and the error was gone. 不知怎么的,日食似乎隐藏了这些东西。

我发生了同样的错误,每次我修复它时,它都会在我重新启动 Eclipse 之后返回。

首先,正如其他人所说的那样,确保你没有同一份文件的多个副本。项目周围的 jar 文件。

在我的例子中,我有一个使用 ActionBarSherlock 的主项目(在其他库项目中)。对我起作用的诀窍是进入 ActionBarSherlock --> Properties --> Java Build path --> Order of Export并取消选择 Android Private Libraries。然后进入 Project -> Clean,现在您应该能够正确地构建项目。

现在,由于某种原因,每次重新启动 Eclipse 时,它都会自动启用该复选框,因此我必须再次重复这个过程。

希望这能帮助一些迷失的灵魂:)

以防其他人像我一样在这个问题上撞到头:

我的案例涉及到一系列的图书馆项目,简单的做一个清理所有图书馆的项目就可以解决所有的问题

对我来说,只需要转到 Project Properties > > Java Build Path > > Order and Export。取消选中所有外部库,如下图所示。对我有用。希望这个能帮上忙。

Project Properties

我也有同样的问题。我不得不删除 .apk文件,然后它工作了。

I found below solution in eclipse...hope it works for you :)

Right click on the Project Name


Select Java Build Path, go to the tab Order and Export


Unchecked your .jar library's

当多次将同一个库添加到项目中时,会发生此问题。如果您没有故意多次添加库,请查看您在项目中添加的库的依赖项/私有库,很可能它们已经包含了导致这种冲突的库。

一开始我的问题是:

无法执行 dex: java.nio. BufferOverflow 异常。请检查 Eclipse 日志中的堆栈跟踪。

1) I Right click on my project -> Android Tools -> Add Support Library (运行我的应用程序... 没有工作,所以我继续...) 2) 右击在我的项目上-> 属性-> Android-> 检查 Android 4.1.2(16)在项目构建目标上 (再次运行应用程序... ... 然后得到这个:

无法执行 dex: 多个 dex 文件定义 Landroid/support/v4/app/BackStackState;

3)所以我在我的项目中使用了 “ lib”文件夹,而 删除是 < strong > “ old”Android.support. library. jar (Run the app and cross fingers and...)

成功了!

希望它能帮到别人... 谢谢大家!

I was also struggling to find this is issue. In my case what happened is while copying the apk to email (drag drop) - by mistake the apk was pasted in src folder in one of the packages. 从源文件夹中删除 apk 之后,它工作得很好。

我在 Intellij 遇到过这个问题,因为我添加到项目中的 ActionbarSherlock 库将 android-support-v4.jar 定义为一个编译依赖项,而这个 jar 已经包含在我的项目中,所以在编译时有多个版本的 DEX 拷贝。

解决方案是将这个 jar 的 ActionBarSherlock 模块依赖关系更改为 Runtime 而不是编译,因为我的项目已经提供了这个依赖关系。

转到项目/属性和 Java 构建路径,取消选中 Android 私有库

我遇到过这个问题,但这并不意味着同一个库被加载了很多次,而是 System 试图同时加载一个具有相同名称和可能具有相同包名称的类,即。

  • library1.jarcom.pack1.deClass Geometry

还有另一个

  • library2.jar.com.pack1.deClass Geometry

你应该怎么做? You should analyze which methods are being used, a method of library1.jar or library2.

有两种解决方案,

  1. Rename a packagename and then dalvik interprets, that they are distinct classes
  2. Or if you want to risk, purge the class, which doesn't contain the methode, which we really use.

我希望这已经澄清了这个经常被问到的问题。

For me the issue was that, i had added a lib project(autobahn lib) earlier and later switched the to Jar file of the same library.Though i had removed references to the older library project, i was getting this error. 跟随所有的答案在这里我检查了构建路径等。但是我没有手动添加这些库来构建 path。所以我没有东西可以移除。 终于找到了这个文件夹。

Bin/dexedLibs

我注意到有两个同名的 jar 文件与 autobahn Android 相对应,这引起了冲突。所以我删除了 dexedLibs 文件夹中的所有 jar 文件并重建了项目。解决了问题。

我从构建路径中删除了 Android 的依赖项,它工作了。

对我来说,我从 lib 文件夹中删除了 android-support-v4.jar,也从构建路径中删除了它。

为了添加无数其他潜在的资源... ... 我已经更新了我项目的 lib文件夹中的所有库,但后来 Eclipse“有益地”重新安装了所有原始库。Eclipse 内部不再有任何关于这些库的引用,但是外部 dex-maker 程序抓取了 lib目录中的所有文件,因此获得了几个库 .jar文件的两个版本。

git status identified the new files and git clean -f got rid of them for me (though I sometimes had to wait or restart Eclipse on Windows because it still had the files open from the copy).

  • 右键单击项目,转到 build Path>configuration build path
  • 选择库选项卡并单击 support-v4 library和单击删除
  • 点击 OK

然后清理您的项目并运行它将工作: -)

超简单的解决方案和最好的:

删除除 Android X.Y (其中 X.Y 是 Android 中的版本)之外的所有内容,右击 Main Project 的文件夹-> 属性-> Java Build Path。清洁,建造。成交!

在此之前确保只有一个 android-support-v4.jar。

如果您正在使用 cordova,请尝试 Cordova 没问题命令