Unable to execute dex: Multiple dex files define

JavaAndroid

Java Problem Overview


I know this question has been asked here a few times before. But i haven't seen any possible solution yet. Before i make the project 'Run as Android Application' , if i do not clean it, i receive the following error and have to restart Eclipse ... and clean again.

Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define
     Lcom/jstun/core/attribute/MessageAttributeInterface;

com.jstun.core... is a part of my src folder, of course i can't remove it. And even if i remove that package, another package will show up as an error like:

Unable to execute dex: Multiple dex files define
     Landroid/support/v4/app/ActivityCompatHoneycomb;

I've seen this error since updating to ADT 15, i'm using Eclipse Galileo on Ubuntu Do you have any idea? Thanks for any reply!

Java Solutions


Solution 1 - Java

This is a build path issue.

  • Make sure your bin folder is not included in your build path.

  • Right click on your project -> go to properties -> Build Path.

  • Make sure that Honeycomb library is in your libs/ folder and not in your source folder.

  • Include the libraries in libs/ individually in the build path.

    BTW, you may want to bring in the android-support-v4 library to get Ice Cream Sandwich support instead of the Honeycomb support library.

Solution 2 - Java

I have encountered a similar error today and the reason was that the support library was referenced by two library projects used by my app project but with different versions.

In more details: My app depends on 2 library projects

  • FaceBookSDK 3.0 -> which is referencing android-support-v4
  • ActionBarSherlock -> which is referencing android-support-v4 but with a modified version to support maps.

To solve the problem I had to make FaceBookSDK library depend on ABS library instead of the support library directly.

Solution 3 - Java

Well for me, I deleted the file in the libs folder called android support v4.jar and it all worked out. Goodluck :)

Solution 4 - Java

I had the same error happening and every time I fixed it, it would come back after I restarted Eclipse.

First of all, as other people said, make sure you do not have multiple copies of the same .jar file around your projects.

In my case, I had a main project that used ActionBarSherlock (among other library projects). The trick that worked for me was going into ActionBarSherlock --> Properties --> Java Build path --> Order of Export and unselecting Android Private Libraries. Then going into Project -> Clean and now you should be able to build the project correctly.

Now, for some reason, every time I restart Eclipse, it automatically enables that checkbox, so I have to repeat this process again.

Hope this helps some lost soul out there :)

Solution 5 - Java

Go to Project/properties and Java Built Path and unchecked the Android Private Libraries

Solution 6 - Java

To me, just go to Project Properties >> Java Build Path >> Order and Export. Uncheck all external library, as the image bellow. It work for me. Hope this help.

Project Properties

Solution 7 - Java

I have also faced this problem in my project. AVD is not able to reload assets,lib,res and etc folder contexts. problem : Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl.

Then,I created new projects and copied MainActivity.java,activity_main.xml, drawable context. Then delete old project from package explore,restart your Eclipse and AVD. My project is now working properly.... :) I hope this steps will help u little bit folks..!!

Solution 8 - Java

I have same issue, what i tried is:

  1. List item
  2. Open Project Build Path,
  3. Select "Libraries" tab,
  4. Remove all library except the Android Library
  5. Adding all required JARs Files,
  6. And Done!

It works for me, thanks.

Solution 9 - Java

If some of you facing this problem with facebook-connent-plugin for phonegap

try to remove files in bin/class/com/facebook/android directory ! -> and rebuild

Solution 10 - Java

As others mentioned, this occurs when you have multiple copies of the same class in your build path, or elsewhere in your setup.

I had added android-support-v4.jar to my libs/ folder, and somehow eclipse added a second copy to bin/classes/android-support-v4.jar.

You can test for this with > grep -r YourOffendingClassName YourApp | grep jar

Deleting the extra copy in bin/classes solved the problem - unsure why Eclipse made a copy there.

Solution 11 - Java

I got this error for another reason. I was mistaking adding both the v4 AND the v13 support library. This was not necessary for me since my minSdkVersion is 15.

I fixed it by only including the v13 support library. Also, make sure to check mark the library in your exported library build path in eclipse. I also moved it to the top.

Solution 12 - Java

Even after going through multiple answers, no solution worked for me.

I deleted "Android Dependencies" from the build path. Added all the jar files again to the build path and the error was gone. Somehow eclipse seemed to cache the things.

Solution 13 - Java

I'm leaving this answer for someone who gets in this scenario as I did.

I stumbled here and there before noticing that I mistakenly dragged and dropped the Support Library JAR file into my src folder and it was lying there. Since I had no idea how it happened or when I dropped it there, I could never imagine something was wrong there.

I was getting the same error, I found the problem after sometime and removed it. Project is now working fine.

Solution 14 - Java

The Solution for me was just to do following things:

  1. ->lib directory in your project and delete any multiple elements.
  2. Project->Properties->Java build Path and delete any Dependency Library was added automatically and not by you! ->Apply
  3. Restart Eclipse IDE
  4. Now Clean the project.
  5. Run/Debug on Device/Emulator the project ... Good Luck

Solution 15 - Java

My problem at first was:

> Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.

  1. I Right click on my project -> Android Tools -> Add Support Library (Run my app...Didn't work so I keep it going...)
  2. Right click on my project again -> Properties -> Android -> Check Android 4.1.2 (16) on Project Build Target (Run the app again...and get this:

> Unable to execute dex: Multiple dex files define Landroid/support/v4/app/BackStackState;

  1. So I went to the "lib" folder on my project and delete the "old" Android.support.library.jar (Run the app and cross fingers and...)

¡IT WORKS!

Hope it helps someone...Thanks people!

Solution 16 - Java

I have had this issue and that doesn't mean, that the same library is loaded many times but System is trying to load a class with the same name and possibly same package name simultaneously, i.e.

  • com.pack1.de and Class Geometry of library1.jar

and another

  • com.pack1.de and Class Geometry of library2.jar.

How should you approach? You should analyze which methods are being used, a method of library1.jar or library2.

There are 2 Solutions,

  1. Rename a packagename and then dalvik interprets, that they are distinct classes
  2. Or if you want to risk, purge the class, which doesn't contain the methode, which we really use.

I hope that has clarified this often asked question.

Solution 17 - Java

I removed Android dependencies from build path and it worked.

Solution 18 - Java

This error happened to me when in my app's project I referenced a Library project in my Eclipse workspace (in my case the Facebook SDK) and at the same time included the Facebook SDK as a jar in the libs folder. Removing the library reference but keeping the jar in the libs folder removed the error.

Solution 19 - Java

I had same problem. I had to delete the .apk file and then it worked.

Solution 20 - Java

For me I deleted android-support-v4.jar from lib folder and also removed from build path.

Solution 21 - Java

  • Right click on project and go to build Path>configuration build path
  • Select library tab and click on support-v4 library and click on remove
  • Click on OK

and then clean your project and run it will work :-)

Solution 22 - Java

In case anyone else bangs their head on this issue like I just did:

My case involved a chain of library projects. Simply doing a project clean on all of the libraries fixed everything

Solution 23 - Java

I found below solution in eclipse...hope it works for you :)

Right click on the Project Name

Select Java Build Path, go to the tab Order and Export

Unchecked your .jar library's

Solution 24 - Java

This problem occurs when a same library is added into your project multiple times. If you haven't added the library multiple times intentionaly, check out the dependency/private libraries of the libraries you have added in your project, most probably they have already included a library which is causing this conflict.

Solution 25 - Java

I was also struggling to find this is issue. In my case what happened is while copying the apk to email (drag drop) - by mistake the apk was pasted in src folder in one of the packages. After removing the apk from source folder it worked fine.

Solution 26 - Java

I had this problem in Intellij and it was because the ActionBarSherlock library I added to my project defined the android-support-v4.jar as a compile dependency and this jar was already included in my project so there were multiple copies/version of DEX at compile time.

The solution was to change the ActionBarSherlock module dependency for this jar to be Runtime instead of compile, as my project was already providing it.

Solution 27 - Java

For me the issue was that, i had added a lib project(autobahn lib) earlier and later switched the to Jar file of the same library.Though i had removed references to the older library project, i was getting this error. Following all the answers here i checked the build path etc. But i haven't added these libs to build path manually. So i had nothing to remove. Finally came across this folder.

> bin/dexedLibs

I noticed that there were two jar files with the same name corresponding to autobahn Android which was causing the conflict. So i deleted all the jar files in the dexedLibs folder and rebuild the project. That resolved the issue.

Solution 28 - Java

To add the myriad of other potential sources... I had updated all the libraries in my project's lib folder but then Eclipse "helpfully" reinstalled all the original libraries. There was no longer any reference inside Eclipse to these libraries but the external dex-maker program just grabbed all the files in the lib directory and thus got two versions of several library .jar files.

git status identified the new files and git clean -f got rid of them for me (though I sometimes had to wait or restart Eclipse on Windows because it still had the files open from the copy).

Solution 29 - Java

ULTRA simple solution and finest:

Remove everything in Right Click Main Project's Folder -> Properties -> Java Build Path except Android X.Y (where X.Y is the version in android). Clean, and Build. Done!

Make sure before of that to have a single android-support-v4.jar.

Solution 30 - Java

If you are using cordova, try cordova clean command

Solution 31 - Java

Modify the maximun memory parameter in eclipse.ini

-Xmx1024m

And restart your computer.

It worked for me :)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTran Ngu DangView Question on Stackoverflow
Solution 1 - JavaterryView Answer on Stackoverflow
Solution 2 - JavaM.SameerView Answer on Stackoverflow
Solution 3 - JavaakemalFirdausView Answer on Stackoverflow
Solution 4 - JavaHenriqueView Answer on Stackoverflow
Solution 5 - JavaPravin BhosaleView Answer on Stackoverflow
Solution 6 - JavaHoa HoangView Answer on Stackoverflow
Solution 7 - JavasatyaView Answer on Stackoverflow
Solution 8 - JavaFedy VenomView Answer on Stackoverflow
Solution 9 - JavaSamih AView Answer on Stackoverflow
Solution 10 - JavachaqkeView Answer on Stackoverflow
Solution 11 - JavaRyan RView Answer on Stackoverflow
Solution 12 - JavaJaydeepWView Answer on Stackoverflow
Solution 13 - Javakishu27View Answer on Stackoverflow
Solution 14 - JavaGuyNView Answer on Stackoverflow
Solution 15 - JavadarosView Answer on Stackoverflow
Solution 16 - Javauser3635389View Answer on Stackoverflow
Solution 17 - JavaCüneytView Answer on Stackoverflow
Solution 18 - JavaonosendaiView Answer on Stackoverflow
Solution 19 - JavasoduncuView Answer on Stackoverflow
Solution 20 - JavaRachView Answer on Stackoverflow
Solution 21 - JavaIman MarashiView Answer on Stackoverflow
Solution 22 - JavaJoe PlanteView Answer on Stackoverflow
Solution 23 - JavaHarshal BenakeView Answer on Stackoverflow
Solution 24 - JavaUmer FarooqView Answer on Stackoverflow
Solution 25 - JavaPrabakaranView Answer on Stackoverflow
Solution 26 - JavaTimTView Answer on Stackoverflow
Solution 27 - JavaAjith MemanaView Answer on Stackoverflow
Solution 28 - JavaBrian WhiteView Answer on Stackoverflow
Solution 29 - JavaAndrés FgView Answer on Stackoverflow
Solution 30 - JavaMerbin JoeView Answer on Stackoverflow
Solution 31 - JavaTruncarlosView Answer on Stackoverflow