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

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

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

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


当前回答

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

这就是我遇到的问题:

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!

其他回答

这些答案对我都没用。我的问题是由JUnit和hamcrest引起的。参见java.lang.IllegalArgumentException: already added: Lorg/hamcrest/BaseDescription;转换到Dalvik格式失败,错误1

我用另一种方法找到了解决办法。 https://stackoverflow.com/a/14948244/1014288

多亏了这个,你可以修复没有删除和东西

没有什么能帮到我,但这里建议的解决方案非常有效:

例如,将-optimizations !code/allocation/variable添加到proguard-project.txt中

我正在使用ADT r14,当我尝试添加任何库项目时,我得到了这个错误。对我来说,有效的方法就是将ADT更新到最新版本。它立刻解决了问题。我尝试了几乎所有的工作给stackoverflow,但没有其他真正为我工作。

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

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