Friday, 6 April 2012

Eclipse/Android error: "Multiple dex files define [...]"


Wow, I am really going nuts blogging this-evening - 2nd post in less than an hour. 


Anyway this is a particularly nasty error that I keep running into with Eclipse/Android when starting the emulator after I have not run it for a little while. Since I run the risk of permanently forgetting the solution to the problem every time I walk away from my Android project (and thus having to spend a painful hour-or-so digging up the procedure again), I will blog it here, for my benefit, and for the benefit of anyone who may also suffer the same problem.


The gist is that when you start the emulator in debug mode (that is, you hit the button in the following image), you get the following error message come out on the console and a nasty popup telling you nothing more than there is an error with your program and you need to fix it:








[2012-04-06 23:20:57 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/google/gson/ExclusionStrategy;
[2012-04-06 23:20:57 - SimpleList] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/gson/ExclusionStrategy;




Perhaps you're not using GSON, as I am, but some other library or archive. My understanding is that this issue is not limited to GSON.


So, the way to deal with it (which so-far seems to work without fail for me), is to go to your project directory and delete all files with the suffix "dex" or "apk", and then restart Eclipse. I have no idea what the cause is, but this seems to do the trick. Good luck!




No comments:

Post a Comment