在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!

其他回答

最好将所有*.jar文件包含在项目文件夹树的“lib”目录中。这样,您就不需要通过转到项目的属性来定义构建路径。"lib"已经是一个构建路径

在我的案例中,问题在于OpenFeint API项目。我添加了OpenFeint作为库项目:

.

它也被添加到构建路径中,ADT tools 16在此场景中给出错误。

右键单击你的项目,单击构建路径,配置构建路径,然后看到图像,并从这里删除你的项目OpenFeint,一切都完成了:)

通常对我来说,清理项目并不能解决这个问题。

但是在Eclipse中关闭项目,然后重新打开它似乎可以修复这些情况……

在我的情况下,我有一个外部罐子添加。因此,我将外部jar位置移动到Project Prop中的android引用的顶部——>Java buildPath——>项目引用

这个错误是由于我从构建路径中排除的几个文件被删除了,但没有从排除列表中删除。

项目->属性-> Java Build Path -> Source选项卡->项目/src文件夹->双击排除->删除项目中不再存在的任何文件。