在Eclipse中的Android应用程序中,我得到了以下错误。
意想不到的顶级异常: java.lang.IllegalArgumentException:已添加:Lorg/xmlpull/v1/XmlPullParser; .... 转换到Dalvik格式失败,错误1
此错误仅在向项目添加特定的外部JAR文件时出现。我花了很长时间寻找可能的解决方案,但没有一个可行。
我甚至尝试将Android 1.6而不是1.5(我目前使用的版本)。
在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!
其他回答
这里的答案对我的情况没有帮助。
对我来说,问题是mvn eclipse:eclipse正在生成一个类路径条目,这是一个Android库项目的项目引用,然而,它没有显示在eclipse构建路径设置!这意味着库类在dexer中结束了两次,一次来自隐藏的项目引用,一次来自链接库JAR。
我必须用文本编辑器打开.classpath并手动删除projects元素。这解决了问题。
没有什么能帮到我,但这里建议的解决方案非常有效:
例如,将-optimizations !code/allocation/variable添加到proguard-project.txt中
我用另一种方法找到了解决办法。 https://stackoverflow.com/a/14948244/1014288
多亏了这个,你可以修复没有删除和东西
对于仍然有这个问题的其他人,他们尝试了上面的答案但仍然得到错误(这是我的情况),那么我的解决方案是从Eclipse中删除项目并重新导入它。
这使得Android库再次添加到我的引用库中,所以现在我有两个Android JAR文件引用,因此我删除了其中一个,现在它编译良好。
解决方案:从Eclipse IDE中删除项目,然后重新导入,然后检查上述解决方案。
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