Unable to execute dex: Multiple dex files define

2019-01-01 06:53发布

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 android
30条回答
栀子花@的思念
2楼-- · 2019-01-01 07:19

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.

查看更多
时光乱了年华
3楼-- · 2019-01-01 07:19

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.

查看更多
临风纵饮
4楼-- · 2019-01-01 07:19

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.

查看更多
倾城一夜雪
5楼-- · 2019-01-01 07:23

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

查看更多
梦该遗忘
6楼-- · 2019-01-01 07:23
  • 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 :-)

查看更多
临风纵饮
7楼-- · 2019-01-01 07:24

I removed Android dependencies from build path and it worked.

查看更多
登录 后发表回答