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

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

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

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


当前回答

此错误是由于

拥有多个JAR文件。 如果JAR文件具有类似的类文件,则不能解析.dx格式。

解决方案:

制作并选择适当的JAR文件。 买最新的。

其他回答

通常,当构建路径中存在不必要的JAR文件时,似乎就会出现这个问题。

我在开发IntelliJ IDEA时遇到了这个问题。对我来说,这是因为我添加了JUnit和Mockito库,它们在运行时被编译。这需要在模块属性中设置为“testing”。

Windows 7解决方案:

确认该问题是由文件中的ProGuard命令行导致的 [Android SDK安装目录]\tools\proguard\bin\proguard.bat

编辑下面这行就可以解决问题了:

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*

to

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9

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

这就是我遇到的问题:

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!

更新Proguard到最新版本为我解决了这个问题。

我的proguard路径是C:\Program Files (x86)\Android\ android-sdk\tools\proguard\ 我从这里下载了新版本 并替换了bin和lib文件夹

感谢上帝!

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

.

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

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