Unable to execute dex: Multiple dex files define L

2018-12-31 03:28发布

Since updating to ADT 14 I can no longer build my project. 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.
  • 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
  • Re-installing Eclipse (updated to the latest version 3.7.1)
  • Created a new project importing from the file system
  • Created a new project from subversion.

30条回答
有味是清欢
2楼-- · 2018-12-31 03:53

After reading Terrys response about deleting the bin directory and Larrys about the the location of the ANT directory:

I moved the files located in my projects BIN directory to the BIN/CLASSES and im up and running.

Edit 1 Then failed on second run...doh

Edit 2 So closed Eclipse moved files back to original location and its all working... um what? I don't pretend to know why this worked. Will update if any changes.

Edit 3 I have noted from my backups that there were indeed duplicate files in the BIN directory and BIN/CLASSES.

So the answer is: don't have files in both locations. At least for me that's what worked.

查看更多
荒废的爱情
3楼-- · 2018-12-31 03:54

Select the project in Project Explorer, right-click and select Properties -> Java Build Path -> Source -> Check the box for Allow output folders for source folders

查看更多
忆尘夕之涩
4楼-- · 2018-12-31 03:56

I removed Android dependencies from build path and it worked.

Edit: ignore that. I had same jar in my maven dependencies and libs folder. I removed the one at the lib folder.

查看更多
后来的你喜欢了谁
5楼-- · 2018-12-31 03:56

[Solved for me]

by removing the duplicate library "JAR file" then remove BuildConfig.java file, Clean project and its work.

查看更多
忆尘夕之涩
6楼-- · 2018-12-31 03:57

I had the same problem, quite weird because it was happening only when using Eclipse (but it was OK with Ant). This is how I fixed it:

  • Right click on the Project Name
  • Select Build Path -> Configure Build Path
  • In Java Build Path, go to the tab Order and Export

  • Uncheck your .jar library

Only sometimes: In Order and Export tab I did not have any jar library there, so I have unchecked Android Private Libraries item. Now my project is running.

查看更多
像晚风撩人
7楼-- · 2018-12-31 03:57

For me this problem only exists as long as there are Android library projects involved in my project. So when I remove all the libraries and do as you said I can run my app again. If there are libraries involved even the bin-removal-trick trick won' work.

I don't get why this bug first appeared today since I'm using ADT 14 for several days now. Well there were other bugs that kept me happy though.

查看更多
登录 后发表回答