“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:47

Just for the other people who still have this problem and they have tried the above answers but still getting the error (which was my case), then my solution was to delete the project from Eclipse and re-import it again.

This made the Android library to be added again to my referenced libraries, so now I have two Android JAR files referenced, hence I deleted one of them and now it compiles fine.

Solution: Delete the project from Eclipse IDE and then re-import it again, then check for the above solutions.

查看更多
忆尘夕之涩
3楼-- · 2018-12-31 01:50

I've dealt with this problem when using Sherlock ActionBar library in my project. You could do the following step, it's work for me.

  1. Right click to your project, select properties.
  2. A dialog will show up, select 'Java build path' on the left menu.
  3. Remove 'Android dependencies' and 'Android private libraries' on the right panel then click OK
  4. Clean your project (select menu Project --> Clean)
  5. Right click your project, select Android Tools -> Fix project properties
  6. Clean project once again.
  7. Restart your computer
  8. Open eclipse and Export apk

Hope that will help you.

查看更多
素衣白纱
4楼-- · 2018-12-31 01:50

None of previously proposed solutions worked for me. In my case, the problem happened when I switched from referencing a library source code folder to using the library JAR file. Initially there was an Android library project listed under the Android application project Properties\ Android page\ Library section, and the library compared also in project explorer tree as a link to the library source directory.

In the first place, I just deleted the directory link from the project tree and I added the JAR library to the build path, but this caused the exception.

The correct procedure was (after changing back the build path and putting back the reference to the library source):

  • properly remove the library source directory link by actually removing the reference from application project Properties\ Android page

  • adding the library JAR to the application project build path as usual.

查看更多
十年一品温如言
5楼-- · 2018-12-31 01:51

My own and only solution that I found today after four hours of testing all the solutions, is a combination of many solutions provided here:

  • Delete project from Eclipse
  • Delete files in \bin and \gen from project folder
  • Remove references to libraries into .classpath file in root project folder
  • Restart Eclipse with command line : eclipse -clean
  • Import project
  • Right click on project - select Properties > Java Build Path > Libraries and remove everything else than Android XX.Y
  • Finally clean project, wait for automatic Building or Build it
  • Launch and now it works! At least for me...

I tried every step at a time and many combinations, but only the succession of all steps at once made it! I hope I won't face this again...

查看更多
骚的不知所云
6楼-- · 2018-12-31 01:54

I ran into this problem but my solution was twofold. 1.) I had to add an Android target version under project -> properties -> Android. 2.) I didn't have all google 'third party add-ons'. Click in AVD SDK manager under available packages -> third-party add-ons -> Google Inc. I downloaded all of the SDKs and that solved my issue.

查看更多
公子世无双
7楼-- · 2018-12-31 01:55

You can solve this issue easily (with Eclipse Android Developer Tools, Build: v22.0.1-685705) by turn off menu > "Project" > "Build Automatically" while exporting (un)signed Android application. After that, don't forget to turn it on again.

查看更多
登录 后发表回答