在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(我目前使用的版本)。
当前回答
我的问题是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中的构建。 我希望它能帮助到一些人。
其他回答
上面列出的解决方案没有一个对我有效。
这就是我遇到的问题:
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!
您可以通过关闭菜单>“项目”>“自动构建”来轻松解决这个问题(使用Eclipse Android开发工具,构建:v22.0.1-685705),同时导出(unsigned) Android应用程序。之后,别忘了再打开它。
在我的案例中,问题在于OpenFeint API项目。我添加了OpenFeint作为库项目:
.
它也被添加到构建路径中,ADT tools 16在此场景中给出错误。
右键单击你的项目,单击构建路径,配置构建路径,然后看到图像,并从这里删除你的项目OpenFeint,一切都完成了:)
这些答案对我都没用。我的问题是由JUnit和hamcrest引起的。参见java.lang.IllegalArgumentException: already added: Lorg/hamcrest/BaseDescription;转换到Dalvik格式失败,错误1
我使用adt7和其他修复没有工作(但我仍然做了他们)。
然后我复制了proguard.cfg从另一个项目,并简单地粘贴到旧的ADT项目文件夹。哇,成功了。