Multiple dex files error when compiling with ant or Eclipse

Rob picture Rob · Oct 21, 2011 · Viewed 21.5k times · Source

I am unable to build my application I am running the latest build tools downloaded today, this started happening after the update.

-dex:
   [dex] Converting compiled files and external libraries into 
         /Users/rob/Repos/my_app/bin/classes.dex...
    [dx] 
    [dx] UNEXPECTED TOP-LEVEL EXCEPTION:
    [dx] com.android.dx.util.DexException: Multiple dex files define 
         Lcom/robaldred/myapp/About$1;

I have tried cleaning and rebuilding, I've also tried in Eclipse but it gives the same error. Anyone got any ideas? I'm at a brick wall here now.

Answer

Mazed picture Mazed · Oct 28, 2011

I spent hours cleaning, creating new projects, uninstalling-reinstalling sdk... nothing worked. I didnt have any library project either ( i just had some jar files under lib). Howerver, In the end I fixed it and my steps were:

  • Search and clean all .apk files ( I had some in .svn folder...grr.. some developer had added some build related folders under svn)
  • delete bin and gen.
  • From eclipse project properties remove reference to library jars, press ok. Then again add them back. I had some java compiled jar library. I don't know why I had to remove and add it back, but that surely was needed.