“Conversion to Dalvik format failed with error 1”

2018-12-31 01:20发布

In my Android application in Eclipse I get the following error.

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/xmlpull/v1/XmlPullParser;
....
Conversion to Dalvik format failed with error 1

This error only appears when I add a specific external JAR file to my project. I searched for a long time for the possible solution, but none of the possible solutions work. I even tried to change to Android 1.6 instead of 1.5 (the current version I use).

30条回答
姐姐魅力值爆表
2楼-- · 2018-12-31 01:59

Often for me, cleaning the project DOES NOT fix this problem.

But closing the project in Eclipse and then re-opening it does seem to fix it in those cases...

查看更多
呛了眼睛熬了心
3楼-- · 2018-12-31 02:00

Updating Proguard to latest version solved it for me.

  • My proguard path was C:\Program Files (x86)\Android\android-sdk\tools\proguard\
  • I downloaded the new version from here
  • and replaced both bin and lib folders

THANK GOD!

查看更多
十年一品温如言
4楼-- · 2018-12-31 02:02

Here's another scenario, and solution:

If you run into this problem recently after updating the ADT for Eclipse:

  1. In your app project, check for any linked source folders pointing to your library projects (they have names in the form "LibraryName_src").
  2. Select all those projects, right-click, choose "Build Path"->"Remove from Build Path".
  3. Choose "Also unlink the folder from the project", and click "Yes".
  4. Clean, rebuild and redeploy the project.

It seems the reason is that some previous version of ADT linked Library project source folders to the "child" projects, and the current ADT/Dex combination isn't compatible with that solution anymore.

EDIT: this is confirmed by an Android Dev Blog entry, specifically this one - see the 8th paragraph onwards.

查看更多
零度萤火
5楼-- · 2018-12-31 02:02

In my case the problem is actually with OpenFeint API project. I have added OpenFeint as library project:

library project]![1]![Enter image description here.

It is also added into build path, ADT tools 16 gives error with this sceneario.

Right click on your project and click build path, configure the build path and then see the image and remove your project OpenFeint from here and all is done :)

Enter image description here

查看更多
只靠听说
6楼-- · 2018-12-31 02:02

None of the listed solutions worked for me.

Here's where I was having a problem:

I added the jSoup external JAR file to my project's path by first putting it in a source folder called "libs", and then right clicking on it, Build Path -> add to build path. This threw the Dalvik conversion error. It said I had "already included" a class from that JAR file. I looked around the project's directory and found that the place where it was "already included" was in fact the bin directory. I deleted the JAR file from the bin directory and refreshed the project in Eclipse and the error went away!

查看更多
流年柔荑漫光年
7楼-- · 2018-12-31 02:02

I had the same problem and none of these solutions worked. Finally, I saw in the console that the error was due to duplicated class (one in the existing project, one in the added jar file) :

java.lang.IllegalArgumentException: already added: package/MyClassclass;
[2011-01-19 14:54:05 - ...]: Dx1 error; aborting
[2011-01-19 14:54:05 - ...] Conversion to Dalvik format failed with error 1

So check if you are adding jar with duplicated classes in your project. If yes, try removing one of them.

It worked for me.

查看更多
登录 后发表回答