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

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

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

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


当前回答

我遇到了这个问题,因为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>

其他回答

您可以通过关闭菜单>“项目”>“自动构建”来轻松解决这个问题(使用Eclipse Android开发工具,构建:v22.0.1-685705),同时导出(unsigned) Android应用程序。之后,别忘了再打开它。

只有>清洁项目对我有用。

以前我有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。我解决了这个问题。

我把我的答案贴在这里,这样如果有人遇到这个问题,他们就能解决它。

这让我很沮丧。希望能帮助别人。

我也犯了同样的错误,我尝试了上面所有的方法,但都无济于事。

我的项目是挂在GIT源码管理系统上的,在导出到android应用的过程中,我发现有一些GIT相关的任务。然后我将所有更改提交到GIT存储库,错误消失了。

因此,如果您正在使用GIT进行源代码控制,而上述方法对您没有任何帮助,请尝试将所有更改提交到GIT存储库(并最终推到上游),然后再次尝试导出。

另一个机器人巫术的案例 如果其他方法都不管用,那就试试 将清单中的versionCode和versionName增加1。

这对我很管用。