“Conversion to Dalvik format failed with error 1”

2018-12-31 01:20发布

In my Android application in Eclipse I get the following error.

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/xmlpull/v1/XmlPullParser;
....
Conversion to Dalvik format failed with error 1

This error only appears when I add a specific external JAR file to my project. I searched for a long time for the possible solution, but none of the possible solutions work. I even tried to change to Android 1.6 instead of 1.5 (the current version I use).

30条回答
查无此人
2楼-- · 2018-12-31 01:40

In my case

project->properties->java build path -> in order and export tab -> uncheck android-support-v4.jar

查看更多
时光乱了年华
3楼-- · 2018-12-31 01:41

I ran into this problem because the Android-Maven-plugin in Eclipse was apparently not recognizing transitive references and references referenced twice from a couple of projects (including an Android library project), and including them more than once. I had to use hocus-pocus to get everything included only once, even though Maven is supposed to take care of all this.

For example, I had a core library globalmentor-core, that was also used by globalmentor-google and globalmentor-android (the latter of which is an Android library). In the globalmentor-android pom.xml I had to mark the dependency as "provided" as well as excluded from other libraries in which it was transitively included:

    <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>

Then in the final application pom.xml I had to use the right trickery to allow only one inclusion path---as well as not explicitly including the core library:

    <!-- 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>
查看更多
素衣白纱
4楼-- · 2018-12-31 01:42

I solved the problem.

This is a JAR file conflict.

It seems that I have two JAR files on my buildpath that include the same package and classes.

smack.jar and android_maps_lib-1.0.2

Deleting this package from one of the JAR files solved the problem.

查看更多
不再属于我。
5楼-- · 2018-12-31 01:42

For me, an extra JAR reference had appeared in my build path. I deleted this, and it works now.

查看更多
牵手、夕阳
6楼-- · 2018-12-31 01:42

All the solutions above didn't work for me. I'm not using any precompiled .jar. I'm using the LVL and the Dalvik errors where all related to the market licensing library.

The problem got solved by deleting the main project and reimporting (create a new project from existing sources).

查看更多
心情的温度
7楼-- · 2018-12-31 01:44

Go to Project and then uncheck "Build Automatically".Then try to export the project and the error is gone.

查看更多
登录 后发表回答