在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(我目前使用的版本)。
当前回答
对我有效的方法如下:
完全清理构建 删除无关的android.jar文件,我发现在项目/属性/库。
其他回答
每种方法我都试过了,但都没用。
有趣的是,如果我们使用proguard导出android应用程序,我们会得到“转换为dalvik格式失败,错误1”的错误,但如果我们在导出时不使用proguard,那么APK就成功创建了。
最后,我们的android项目中有一个jar的.class文件大小超过1.5 MB。它的大小导致了这个问题。我们把那个班分成许多小班,问题就解决了。
上面列出的解决方案没有一个对我有效。
这就是我遇到的问题:
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!
今天我自己也遇到了这个问题。清理和重建并没有解决问题。删除和重新导入项目也没有帮助。
我最终追踪到我的.class文件中的一个坏添加。我认为这是由插件工具添加的,当我试图解决另一个问题时,删除它摆脱了“转换到Dalvik格式失败,错误1”的构建错误:
<classpathentry kind="lib" path="C:/dev/repository/android-sdk-windows/platforms/android-3/android.jar">
<attributes>
<attribute name="javadoc_location" value="file:/C:/dev/repository/android-sdk-windows/docs/reference"/>
</attributes>
<accessrules>
<accessrule kind="nonaccessible" pattern="com/android/internal/**"/>
</accessrules>
对我有效的方法如下:
完全清理构建 删除无关的android.jar文件,我发现在项目/属性/库。
下面是另一个场景和解决方案:
如果您最近在更新Eclipse ADT后遇到这个问题:
在你的应用项目中,检查任何指向你的库项目的链接源文件夹(它们的名称以“LibraryName_src”的形式存在)。 选择所有这些项目,右键单击,选择“构建路径”->“从构建路径中删除”。 选择“也从项目中取消该文件夹的链接”,然后单击“是”。 清理、重新构建和重新部署项目。
原因似乎是ADT以前的一些版本将库项目源文件夹链接到“子”项目,而当前ADT/Dex组合不再与该解决方案兼容。
编辑:这一点在Android开发博客的一篇文章中得到了证实,特别是这篇文章——见第8段。