Multiple dex files - Conversion to Dalvik format failed - Unable to execute dex

Matt picture Matt · Apr 18, 2013 · Viewed 38.2k times · Source

I have 2 app versions - pro and lite. They are both already on the market at v1.01. I am trying to release v1.1 for both. This update includes SwawrmConnect integration in order to use their global leaderboards.

I should start off by saying I know I am not maintaining my code correctly. I have 2 completely separate apps and that share probably 90% of their code. I maintain them separately because after a week or 2 or 3 of failing to figure out how to do a library and share code, I gave up and just went this way with it.

SwarmConnect is the first jar I have used and had to make a library to two apps (see screenshot of file structure below).

Right now my lite version is working and is ready for release. I am now trying to get my pro version to where it needs to be for release. I am fairly certain all java/xml files are up to date and ready. When I went to run the pro version in the emulator, I get the below error:

[2013-04-18 11:24:41 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/swarmconnect/loopj/android/http/AsyncHttpResponseHandler;
[2013-04-18 11:24:41 - BibleTriviaPro] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/swarmconnect/loopj/android/http/AsyncHttpResponseHandler;

Things I've tried:

  • Clean/rebuild
  • Update Eclipse
  • Delete bin and gen folders
  • Restart Eclipse
  • Plus some other stuff

My file structure:

enter image description here

Could the problem be is I am trying to use SwarmConnect as a library for 2 projects (lite and pro)?

EDIT:

Below is the file structure for the lite version that is working perfectly. Compiles and runs on emulator.

enter image description here

Answer

Sriram picture Sriram · Apr 18, 2013

Coincidentally I ran into the same issue just day before yesterday. Here's what I suggest you to do.

First and foremost make sure that you have a backup of all the jars presently residing in the 'Android Dependencies'/'libs' folder.

Now, lets fix the lite version first by following these steps.

  1. Remove all jar files except android-support-v4.jar from the 'Android Dependencies' folder under Project Explorer in Eclipse.

  2. Similarly remove all Jar files except android-support-v4.jar from the libs folder under Project Explorer in Eclipse.

  3. Now Right click on your project-> Select Properties-> Select Java Build Path-> Select Add External JARs. Add all the necessary jar files (just make sure you add a particular jar file only once).

Finally clean the project and build it. Now apply the same sequence of steps to the pro version. That should do it.

UPDATE:- In case you see Eclipse cribbing about some compile time errors after doing all this all you might have to do is to just fix those compile time errors by doing the necessary imports by pressing Ctrl+Shift+O.

[I assume that there's no linkage between the pro and lite versions of the project in terms of source dependencies etc.. what I mean to say basically they are totally independent.]

Hope this helps.