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

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

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

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


当前回答

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

其他回答

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

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

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

另一个机器人巫术的案例 如果其他方法都不管用,那就试试 将清单中的versionCode和versionName增加1。

这对我很管用。

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

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

感谢上帝!

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

这就是我遇到的问题:

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!