Saturday, October 22, 2011

Android ADT 14 Declares War on My Code!

The error comes up only when compiling the project, it started happening when I updated tools in Eclipse to ADT 14, but others had it in prior versions.

Unable to execute dex: Multiple dex files define

Conversion to Dalvik format failed with error 1
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/cyberwalkabout/common/DistanceUtils;




We have been using multiple project libraries for months, but now including them causes a problem as some of them are referenced more than once. 



I found suggestions, however they don't apply to my particular problem as the error is caused by my own library projects



  • remove external jars from build-path and re-add them as the local jar instead
  • remove all external jars and re-added them one at a time making sure they were the right ones
  • removed the .classpath file, bin and gen directories
  • clean the project in Eclipse, forcing the files to be regenerated
  • shuffled around the jar files in the build order
One of the suggestions was to start Eclipse with clean but that did not work either.


uki: /Applications/IDE/eclipse $ ./eclipse clean


Updates (Android ADT 14) in Eclipse Indigo that introduced these problems:





switch() to if-then



Among many, many things that went wrong today this one was was annoying because of many places I had to change, but at least quick to fix.

Android ADT 14 decided that it does not like to use R.id.reference as a parameter to switch statement and it had to me changed to if-then.



So all of the switch statements had to be converted to if-then. Thankfully there is a shortcut for that (command-1).





2 comment(s):

  1. How did you resolve the error "Unable to execute dex: Multiple dex files define"

    ReplyDelete
  2. this error accounts when you reference a library more than once. Simple go to build path of the project and you can see,just remove one reference and here you go.

    ReplyDelete