eclipse 无法执行 dex:多个 dex 文件定义了 Lcom/actionbarsherlock/R$attr

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14742602/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:57:11  来源:igfitidea点击:

Unable to execute dex: Multiple dex files define Lcom/actionbarsherlock/R$attr

androideclipseactionbarsherlockdex

提问by Andreas H

I have created a library project for my app. When I try to add the library to a project, I get the following error when trying to run it:

我为我的应用程序创建了一个库项目。当我尝试将库添加到项目时,尝试运行它时出现以下错误:

[2013-02-07 04:51:26 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/actionbarsherlock/R$attr;
[2013-02-07 04:51:26 - testfromlibrary] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/actionbarsherlock/R$attr;

I have added the HoloEverywhere library to my library, whereas I have added the ActionBarSherlock library to HoloEverywhere. I am using Eclipse on Windows 7.

我已将 HoloEverywhere 库添加到我的库中,而我已将 ActionBarSherlock 库添加到 HoloEverywhere。我在 Windows 7 上使用 Eclipse。

Even though I updated the SDK to the latest version, restarted Eclipse, and cleaned the various projects, the error persists.

即使我将SDK更新到最新版本,重新启动Eclipse,并清理了各个项目,错误仍然存​​在。

Does anyone have any idea on how to solve this error? My bin diris not included to the build path under properties, and I have tried deleting the bin folderaltogether.

有没有人知道如何解决这个错误?我的bin 目录未包含在属性下的构建路径中,我已尝试完全删除 bin 文件夹

Thanks!

谢谢!

采纳答案by Andreas H

I pinpointed the cause of the error to /bin/classes. If I deleted the /classes dir before running the app, the app would compile and run. Of course, when I tried to actually export the app, the /classes dir would come back and along with it the error.

我将错误的原因定位到 /bin/classes。如果我在运行应用程序之前删除 /classes 目录,应用程序将编译并运行。当然,当我尝试实际导出应用程序时, /classes 目录会返回并随之出现错误。

The solution to my problem was to install the latest version of Eclipse. When I export or run the app through the latest installation of Eclipse, the /classes folder does not appear now.

我的问题的解决方案是安装最新版本的 Eclipse。当我通过最新安装的 Eclipse 导出或运行应用程序时,现在不会出现 /classes 文件夹。

回答by Chriskot

I found that if I went into properties -> Java Build Path -> Order and Export and removed the Android Private Libraries then my project built fine. There was another support v4 jar in there which was conflicting with action bar sherlocks support v4 library

我发现如果我进入属性 -> Java 构建路径 -> 订购和导出并删除 Android 私有库,那么我的项目构建得很好。那里有另一个支持 v4 jar,它与操作栏 Sherlocks 支持 v4 库冲突

回答by thalespf

This issue happens to me when I create a library in conjuction with actionbarsherlock. In this case the eclipse create the R from sherlock in my library and in the project using it.

当我与 actionbarsherlock 结合创建一个库时,这个问题发生在我身上。在这种情况下,eclipse 在我的库和使用它的项目中从 Sherlock 创建 R。

The solution is delete in your library bin folder only the folder actionbarsherlock that contains the R classes. This inst create anymore, and is present only in your project app.

解决方案是在您的库 bin 文件夹中仅删除包含 R 类的文件夹 actionbarsherlock。此 inst 不再创建,并且仅存在于您的项目应用程序中。

回答by jony

the issue for me was duplicate class files. i had both the package itself and the jar sdk of the package (in libs folder) in the same project.

我的问题是重复的类文件。我在同一个项目中同时拥有包本身和包的 jar sdk(在 libs 文件夹中)。

回答by methical

This happened to me after I changed a regular android project to a library project in order to use it for a Free/Paid project split set up.

在我将常规 android 项目更改为库项目以便将其用于免费/付费项目拆分设置后,这发生在我身上。

Running either of the Free/Paid projects will result in OPs error.

运行任何一个免费/付费项目都会导致 OP 错误。

Problem was some left over compilation stuff when the base project was a normal project and not a library project. Just clean the workspace and rebuild all projects. Old compilation junk will be removed and everything will be compiled into correct libraries. Try to rerun project which gave the error and everything should be fine now.

当基础项目是普通项目而不是库项目时,问题是一些遗留的编译内容。只需清理工作区并重建所有项目。旧的编译垃圾将被删除,所有内容都将被编译到正确的库中。尝试重新运行出现错误的项目,现在一切正常。

回答by Ton Snoei

Be sure both projects (the library and the app) don't have the same packagename (within the AndroidManifest)

确保两个项目(库和应用程序)没有相同的包名(在 AndroidManifest 中)

回答by Matthew Shearer

I had the same issue today. I deleted the .apk file inside /bin, seemed to fix it.

我今天遇到了同样的问题。我删除了 /bin 中的 .apk 文件,似乎修复了它。

回答by user2918326

Remove all the libraries from Build Path and import the library project that you want to implement.. This works just fine..

从 Build Path 中删除所有库并导入要实现的库项目.. 这工作得很好..

回答by Jorge E. Hernández

You can use Tattletale

您可以使用Tattletale

It helps you to identify duplicated classes in your JAR files.

它可以帮助您识别 JAR 文件中的重复类。

Hope it helps.

希望能帮助到你。

回答by Gene Bo

For Android Studio - I removed duplicate .jar imports and it was resolved.

对于 Android Studio - 我删除了重复的 .jar 导入并已解决。

Details:I had an app that had a base /common folder and then two folders that inherited from that - a free and paid version of the app. The issue was caused when I had the /common folder and the /free folder both including the same crashlytics jar file in project structure.

详细信息:我有一个应用程序,它有一个基本的 /common 文件夹,然后是两个继承自该文件夹的文件夹 - 该应用程序的免费和付费版本。当我在项目结构中包含相同的 crashlytics jar 文件的 /common 文件夹和 /free 文件夹时,会导致该问题。