本文翻译自:Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;
Since updating to ADT
14 I can no longer build my project. 由于更新为ADT
14,因此我无法再构建项目。 It was building fine prior to updating. 在更新之前,它的构建良好。
The error: 错误:
[2011-10-23 16:23:29 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;
[2011-10-23 16:23:29 - myProj] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;
Similar issues have been reported and I have tried the suggestions there including 曾报道过类似的问题,我尝试了其中的建议,包括
- Restarting
Eclipse
. 重新启动Eclipse
。 - Cleaning the project and rebuild - Disable "Project->Build Automatically" option, then "Clean" and "Build" project, then try to run. 清理项目并重建-禁用“项目->自动生成”选项,然后禁用“清理”和“生成”项目,然后尝试运行。 reset "Build Automatically" option to On 将“自动构建”选项重置为“开”
- Re-installing the
Android
Developer Tools 重新安装Android
开发人员工具 - Re-installing Eclipse (updated to the latest version 3.7.1) 重新安装Eclipse(更新到最新版本3.7.1)
- Created a new project importing from the file system 创建了一个从文件系统导入的新项目
- Created a new project from subversion. 从subversion创建了一个新项目。
#1楼
参考:https://stackoom.com/question/X1Pl/无法执行dex-多个dex文件定义了Lcom-myapp-R-array
#2楼
- Close eclipse. 月蚀。
- Delete bin folder inside your project folder. 删除项目文件夹中的bin文件夹。
- Start eclipse and clean your project. 开始蚀并清理您的项目。
- Now run and the problem should be gone 现在运行,问题应该消失了
#3楼
Deleting the bin folder was not enough, I also deleted the gen folder. 删除bin文件夹还不够,我还删除了gen文件夹。 Then after two rebuilds the dex error message was gone. 然后,在两次重建之后,dex错误消息消失了。
#4楼
在Project Explorer中选择项目,右键单击并选择Properties- > Java Build Path- > Source- >选中允许输出文件夹作为源文件夹的框
#5楼
None of the above helped. 以上均无济于事。 It was a simple problem in the end. 最终这是一个简单的问题。
I had a project which uses the FacebookSDK and ViewPagerIndicator as library projects. 我有一个使用FacebookSDK和ViewPagerIndicator作为图书馆项目的项目。 All were built on Android API 16 and those two projects used the android support library vX (X not being 16!) 所有这些都是基于Android API 16构建的,并且这两个项目都使用了android支持库vX(X不是16!)
I added an external JAR to both those projects and pointed it to \\extras\\android\\v4... And also removed the v4 jar I had in their libs folders. 我向这两个项目都添加了一个外部JAR,并将其指向\\ extras \\ android \\ v4 ...,还删除了我在其libs文件夹中的v4 jar。
Clean all projects and re-build. 清理所有项目并重新构建。
Voilla! 瞧!
The exact error I was receiving: Unable to execute dex: Multiple dex files define Landroid/support/v4/view/PagerAdapter; 我收到的确切错误是:无法执行dex:多个dex文件定义了Landroid / support / v4 / view / PagerAdapter; Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/view/PagerAdapter; 转换为Dalvik格式失败:无法执行dex:多个dex文件定义了Landroid / support / v4 / view / PagerAdapter;
#6楼
Modify your eclipse.ini file and set the maximum memory parameter to 修改您的eclipse.ini文件,并将最大内存参数设置为
-Xmx1024m
Then restart your computer. 然后重新启动计算机。
It worked for me. 它为我工作。