Eclipse、Android:意外无法执行 dex:多个 dex 文件定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26089572/
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
Eclipse, Android: Unexpected Unable to execute dex: Multiple dex files define
提问by dephinera
The problem: I can't built my project. When I try the following sign is shown in the Console:
问题:我无法构建我的项目。当我尝试在控制台中显示以下标志时:
[2014-09-28 23:49:30 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/annotation/AnimRes;
[2014-09-28 23:49:30 - Shop] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/annotation/AnimRes;
I lost hours of searching for a solution for this problem, but no result.. I tried to clean the project, to delete the bin folder etc. but nothing worked..
我花了几个小时寻找这个问题的解决方案,但没有结果..我试图清理项目,删除 bin 文件夹等,但没有任何效果..
Please, help, I don't know what to do..
求救,不知道怎么办
采纳答案by dephinera
I couldn't fix it so I ended up by creating new project in a different workspace and copied all the code to the new project. It's not the smartest thing but what can I do..
我无法修复它,所以我最终在不同的工作区中创建了新项目并将所有代码复制到新项目中。这不是最聪明的事情,但我能做什么..
回答by anurag_dake
Remove android-support-annotations.jar from libs folder. As these annotations are already included in recent versions of the android-support-v4.jar file.
从 libs 文件夹中删除 android-support-annotations.jar。因为这些注释已经包含在 android-support-v4.jar 文件的最新版本中。
回答by Juan Antonio
I lost several hours too in this problem but i think that I found a solutión, at least for my. Andoid Studio said me that i had "Multiple dex files define Landroid/support/annotation/AnimRes;" but he said also had a file call inputList.txt that had a bug. Well, i found this file in directory tree and i found in app/build/intermediates/tmp/dex/debugfolder. The file is a simple textfile that had one row for each dependence as support-annotations or androidplot-core with a absolute path.
我在这个问题上也损失了几个小时,但我认为我找到了一个解决方案,至少对我来说是这样。Andoid Studio 说我有“多个 dex 文件定义了 Landroid/support/annotation/AnimRes;” 但他说还有一个文件调用 inputList.txt 有一个错误。好吧,我在目录树中找到了这个文件,我在app/build/intermediates/tmp/dex/debug文件夹中找到了这个文件。该文件是一个简单的文本文件,每个依赖项都有一行作为支持注释或带有绝对路径的 androidplot-core。
I saw several row repeated and i thought that if i remove i solve the problem, but it didn't work.
我看到重复了几行,我想如果我删除我可以解决问题,但它没有用。
Then I searched this route and all .jar are in the same place: app/build/intermediates/pre-dexed/debug/folder, and I saw repeated .jar files and I removed this, after i went to the file and I erased repeated rows too.
然后我搜索了这条路线,所有的 .jar 都在同一个地方:app/build/intermediates/pre-dexed/debug/文件夹,我看到重复的 .jar 文件,我删除了这个,在我去文件后我删除了也重复行。
Then I run my project and the bug disappeared, the problem it solved.
然后我运行我的项目,错误消失了,它解决了问题。
The problem was then: .jar files duplicated in that folder.
问题是:.jar 文件在该文件夹中重复。
Easy!
简单!
回答by arif ardiansyah
I have same problem. I think it was happen because there are modification in bin folder contents when I update project repository with tortoise SVN. I have removed bin, and Eclipse generate new one but the problem still persist. But I resolved problem by removing android dependency library. Here the steps :
我有同样的问题。我认为这是因为当我使用乌龟 SVN 更新项目存储库时,bin 文件夹内容发生了修改。我已经删除了 bin,Eclipse 生成了新的 bin,但问题仍然存在。但我通过删除 android 依赖库解决了问题。这里的步骤:
Select Project -> Right Click -> Select Build Path -> Configure Build Path -> In Libraries tab remove Android Dependencies -> OK. Then clean the project and run again. :)
选择项目 -> 右键单击 -> 选择构建路径 -> 配置构建路径 -> 在库选项卡中删除 Android 依赖项 -> 确定。然后清理项目并再次运行。:)
回答by HCOOL
Remove the library which contains android-support-v4.jar,then add the android-support-v4.jar to buid path direct. By the way,I use Eclipse for IDE.
删除包含android-support-v4.jar的库,然后将android-support-v4.jar直接添加到buid路径中。顺便说一下,我使用 Eclipse 作为 IDE。
回答by Linyun Liu
As the console output said "Multiple dex files define".
正如控制台输出所说的“多个 dex 文件定义”。
Under ther bin/dexedLibs, there many jars with the same name but of different version.
在 bin/dexedLibs 下,有许多名称相同但版本不同的 jar。
I solve it by remove all the duplicated support v4 jars under all the lib folders and make my main project reference to the single one in the library project, then clean the project to rebuild.It works as a charm now.
我通过删除所有 lib 文件夹下的所有重复支持 v4 jar 来解决它,并使我的主项目引用库项目中的单个,然后清理项目以重建。它现在很有魅力。