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

Just clean the project

If this does not work try the other solutions

查看更多
牵手、夕阳
3楼-- · 2018-12-31 01:58

EDIT (new solution):

It looks like the previous solution is only a bypass. I managed to finally fix the problem permanently: In my case there was a mismatch in android-support-v4 files in my project and in the Facebook project that is referenced in my project.

I found this error by performing Lint Check (Android Tools / Run Lint: Check for Common Errors)

My previous solution:

I've tried any possible solution on this site - nothing helped!!!

Finally I've found an answer here: https://groups.google.com/forum/#!topic/actionbarsherlock/drzI7pEvKd4

Easy steps:

Go to Project -> uncheck Build Automatically

Go to Project -> Clean... , clean both the library project and your app project

Export your app as a signed APK while Build Automatically is still disabled

查看更多
人间绝色
4楼-- · 2018-12-31 01:58

My problem was caused by ADT version 12.0 and ProGuard integration. This bug is well documented and the solution is in the documentation

Solution is in here

ProGuard command line

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

I found something else. Android uses the /libs directory for JAR files. I have seen the "Conversion to Dalvik format failed with error 1" error numerous times, always when I made a mistake in my JAR files.

Now I upgraded Roboguice to a newer version, by putting the new JAR file in the /libs directory and switching the class path to the new version. That caused the Dalvik error.

When I removed one of the Roboguice JAR files from the /libs folder, the error disappeared. Apparently, Android picks up all JAR files from /libs, regardless of which ones you specify in the Java build path. I don't remember exactly, but I think Android started using /libs by default starting with Android 4.0 (Ice Cream Sandwich, ICS).

查看更多
浅入江南
6楼-- · 2018-12-31 01:58

I am using Android 1.6 and had one external JAR file. What worked for me was to remove all libraries, right-click project and select Android Tools -> *Fix Project Properties (which added back Android 1.6) and then add back the external JAR file.

查看更多
宁负流年不负卿
7楼-- · 2018-12-31 01:59

If you have ADT revision 12+, you should update your proguard from 4.4 -> 4.6 (as described here). Also, you should leave ...\bin\proguard.bat file in the orginal form.

Just download it from the web, and copy lib folder from downloaded package to the :

[Android SDK Installation Directory]\tools\proguard\lib

查看更多
登录 后发表回答