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

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

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

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


当前回答

您可以通过关闭菜单>“项目”>“自动构建”来轻松解决这个问题(使用Eclipse Android开发工具,构建:v22.0.1-685705),同时导出(unsigned) Android应用程序。之后,别忘了再打开它。

其他回答

对于仍然有这个问题的其他人,他们尝试了上面的答案但仍然得到错误(这是我的情况),那么我的解决方案是从Eclipse中删除项目并重新导入它。

这使得Android库再次添加到我的引用库中,所以现在我有两个Android JAR文件引用,因此我删除了其中一个,现在它编译良好。

解决方案:从Eclipse IDE中删除项目,然后重新导入,然后检查上述解决方案。

我在其类路径中包含protobuf lite (Protocol Buffers by谷歌)的项目中有完全相同的错误。我想原因是我的类路径和项目文件夹中的protobuf-lite.jar是在我以前的机器中构建的。当我下载Maven并重新构建protobuf-lite.jar文件,然后将其作为用户库重新添加到我的项目中时,一切都很正常。

每次出现这种错误时,简单地清理项目对我来说都很有效。

我也有同样的问题。当我检查时,我看到有两个类具有相同的名称,每个类在我添加的外部jar文件中。然后我必须删除一个jar文件。幸运的是,我得到了另一个jar文件1我已经删除。

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

这就是我遇到的问题:

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!