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

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

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

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


当前回答

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

其他回答

我解决了这个问题。

这是一个JAR文件冲突。

我的构建路径上似乎有两个包含相同包和类的JAR文件。

jar和android_maps_lib-1.0.2

从一个JAR文件中删除这个包就解决了这个问题。

我遇到了这个问题,因为Eclipse中的Android- maven -插件显然不能识别传递引用,并且从两个项目(包括一个Android库项目)中引用了两次引用,并且不止一次地包含它们。我不得不使用魔术使所有内容只包含一次,即使Maven应该处理所有这些。

例如,我有一个核心库globalmentor-core,它也被globalmentor-google和globalmentor-android使用(后者是一个Android库)。在globalmentor-android pom.xml中,我必须将依赖标记为“提供的”,并将其从其他库中排除。

    <dependency>
        <groupId>com.globalmentor</groupId>
        <artifactId>globalmentor-core</artifactId>
        <version>1.0-SNAPSHOT</version>
        <!-- android-maven-plugin can't seem to automatically keep this from being
             included twice; it must therefore be included manually (either explicitly
             or transitively) in dependent projects -->
        <scope>provided</scope>
    </dependency>

然后在最后的应用程序pom.xml中,我必须使用正确的技巧,只允许一个包含路径——以及不显式地包括核心库:

    <!-- android-maven-plugin can't seem to automatically keep this from being
        included twice -->
    <!-- <dependency> -->
    <!-- <groupId>com.globalmentor</groupId> -->
    <!-- <artifactId>globalmentor-core</artifactId> -->
    <!-- <version>1.0-SNAPSHOT</version> -->
    <!-- </dependency> -->

    <dependency>
        <groupId>com.globalmentor</groupId>
        <artifactId>globalmentor-google</artifactId>
        <version>1.0-SNAPSHOT</version>
        <exclusions>
            <!-- android-maven-plugin can't seem to automatically keep this from
                being included twice -->
            <exclusion>
                <groupId>com.globalmentor</groupId>
                <artifactId>globalmentor-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.globalmentor</groupId>
        <artifactId>globalmentor-android</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

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

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

我个人通过手动编辑项目设法解决了这个问题。属性文件。

它是什么:

target=android-16
android.library.reference.1=..\\..\\github\\ActionBarSherlock\\library
android.library.reference.2=../../github/android-numberpicker/library

我把它改成这样问题就解决了

target=android-16
android.library.reference.1=../../github/ActionBarSherlock/library
android.library.reference.2=../../github/android-numberpicker/library

使用“修复项目属性”工具未自动修复此文件。

我正在使用ADT r14,当我尝试添加任何库项目时,我得到了这个错误。对我来说,有效的方法就是将ADT更新到最新版本。它立刻解决了问题。我尝试了几乎所有的工作给stackoverflow,但没有其他真正为我工作。