Multiple dex files error when compiling with ant or Eclipse

前端 未结 8 405
猫巷女王i
猫巷女王i 2021-01-12 06:17

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          


        
相关标签:
8条回答
  • 2021-01-12 06:50

    Be very careful about all source files you attach to/have in your project. I found this problem in two situations:

    1. When I have two different android support library jars
    2. When I accidently put in the past some Facebook src not as a library, but directly into my src directory

    So all answers which says that you shouldn't put your bin/ directory into class path are also correct, but in situation where you have error like:

    [2013-08-02 20:22:03 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/facebook/android/AsyncFacebookRunner$1;
    [2013-08-02 20:22:03 - Activity] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/facebook/android/AsyncFacebookRunner$1;
    

    you should look for same jars in project/libraries (this should be founded by Android Eclipse environment in most cases) or look into all sources attached to project to find multiple occurance of (as in example code above) of class com.facebook.android.AsyncFacebookRunner

    0 讨论(0)
  • 2021-01-12 06:57

    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.
    0 讨论(0)
  • 2021-01-12 07:00

    If you're having issues because of Multiple DEX files

    Remove the entire target folder and build the project again. This won't affect your project cause everything in the target folder is built again.

    0 讨论(0)
  • 2021-01-12 07:05

    I was seeing this same problem. If you're using Android Studio, you need to make sure you don't have the 'bin' or 'gen' folders included in any of your projects when you're compiling.

    After removing this I was able to compile successfully

    0 讨论(0)
  • 2021-01-12 07:07

    Something happened yesterday to my system (and another here at work) where the SDK wanted to push the platform tools update but then I was unable to use it at all, etc.

    I ended up moving my SDK out of the way and reinstalling it, then everything worked as it always had. I did not have your dex specific issue, but I suspect the update push yesterday broke a good many things. Good luck.

    0 讨论(0)
  • 2021-01-12 07:07

    You can:

    • Delete folders <.settings>, <bin>, <gen>, and files <.classpath>, <.project> and <project.properties>.

    • Delete your project in Eclipse (right button, <Delete>) without deleting the source files.

    • Create a new Android project and select <Create project from existing sources> from your previous sources.

    • Import external libs, if needed in the build path.

    It should solve this annoying problem.

    0 讨论(0)
提交回复
热议问题