在Eclipse中的Android应用程序中,我得到了以下错误。

意想不到的顶级异常: java.lang.IllegalArgumentException:已添加:Lorg/xmlpull/v1/XmlPullParser; .... 转换到Dalvik格式失败,错误1

此错误仅在向项目添加特定的外部JAR文件时出现。我花了很长时间寻找可能的解决方案,但没有一个可行。

我甚至尝试将Android 1.6而不是1.5(我目前使用的版本)。


当前回答

这种情况通常发生在eclipse运行了很长时间之后,或者在我成功地构建了一个带签名的apk之后。

就我的经验而言,修复它我只是重新启动eclipse。

其他回答

我在这里没有工作,我不得不改变我的proguard文件添加这一行:

-keep class !mycode.** { *; }

它保留了任何不是我的包的代码。

我也遇到过同样的问题,但这些方法都不起作用。 最后,我在控制台中看到错误是由于重复的类(一个在现有项目中,一个在添加的jar文件中):

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

因此,请检查您是否在项目中添加了带有重复类的jar。 如果是,请尝试移除其中一个。

这对我很管用。

在我的项目中使用Sherlock ActionBar库时,我已经处理了这个问题。 你可以做下面的步骤,这对我来说是工作。

右键单击项目,选择属性。 将出现一个对话框,在左侧菜单中选择“Java build path”。 删除右边面板上的“Android依赖”和“Android私有库”,然后单击确定 清理项目(选择菜单project—> Clean) 右键单击项目,选择Android工具->修复项目属性 再次清理项目。 重新启动计算机 打开eclipse,导出apk

希望这对你有所帮助。

我个人通过手动编辑项目设法解决了这个问题。属性文件。

它是什么:

target=android-16
android.library.reference.1=..\\..\\github\\ActionBarSherlock\\library
android.library.reference.2=../../github/android-numberpicker/library

我把它改成这样问题就解决了

target=android-16
android.library.reference.1=../../github/ActionBarSherlock/library
android.library.reference.2=../../github/android-numberpicker/library

使用“修复项目属性”工具未自动修复此文件。

上面列出的解决方案没有一个对我有效。

这就是我遇到的问题:

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!