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

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

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

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


当前回答

以前我有Android SDK构建工具18.1.1和Windows XP。然后我的应用程序就正常运行了。

但是我把我的系统更新到Windows 7,还把Android SDK构建工具更新到19,以拥有最新的配置。

但是我的项目有xercesImpl-2.9.1.jar文件,所以当我开始运行我的应用程序与新的/更新的配置,我得到

Conversion to Dalvik format failed with error 1 while parsing org/apache/xerces/impl/xpath/regex/ParserForXMLSchema.class

所以我遍历了所有提到的这个问题的答案,但无法解决。我想了4天,然后我发现了这个链接,救了我的命,读了这篇文章后,我才知道这个问题是由于xercesimpll -2.9.1.jar与Android SDK构建工具到19。

所以我把它降级为Android SDK Build tools到18.1.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!

如果你有ADT版本12+,你应该更新你的防护从4.4 -> 4.6(如这里所述)。此外,您应该以原始形式保留…\bin\proguard.bat文件。

只需从网上下载它,并复制lib文件夹从下载包到:

[Android SDK安装目录]\tools\proguard\lib

我也面临着这个问题,当我添加相同的jar文件与不同的版本,我只是删除旧版本的jar和清洁项目,它为我工作很好。

我的问题是Ant + ProGuard + AdMob SDK库+ Debug模式的集成。我正在使用Ant构建调试APK,并将AdMob SDK JAR添加到libs/目录。Eclipse正常生成调试APK,但Ant不能。我得到了如下错误。

[应用]意想不到的顶级异常: [apply] java.lang.IllegalArgumentException: already added: Lcom/谷歌/ads/AdActivity; [应用]在com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)

我还在build.xml中为调试构建打开了ProGuard(默认是关闭的):

<target name="-debug-obfuscation-check">
    <property name="proguard.enabled" value="true"/>
</target>

这就是问题所在。不知何故,ProGuard和AdMob SDK在调试模式下无法共存。ProGuard没有混淆AdActivity类,所以它出现在bin/ ProGuard / obfusated . JAR中,但同样的类存在于AdMob SDK JAR文件中。Eclipse在没有ProGuard的情况下构建调试APK,所以它工作得很好。

所以我的解决方案是关闭ProGuard来调试build.xml中的构建。 我希望它能帮助到一些人。

如果您在构建路径中添加了Android.jar文件,可能是由于Eclipse中的意外快速修复,也会导致这种情况。删除它右击项目->构建路径->配置构建路径-> android.jar,删除。