java.lang.IllegalArgumentException:已添加:Lorg / hamcrest / BaseDescription;转换为Dalvik格式失败,出现错误1 [英] java.lang.IllegalArgumentException: already added: Lorg/hamcrest/BaseDescription; Conversion to Dalvik format failed with error 1

查看:129
本文介绍了java.lang.IllegalArgumentException:已添加:Lorg / hamcrest / BaseDescription;转换为Dalvik格式失败,出现错误1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,至少有两个帖子有同样的问题,但是这些解决方案不再工作,至少在我的安装中。

First of all, there are at least 2 postings with the same problem but these solutions don't work anymore, at least not in my installation.

m使用m2e与Eclipse和Android,并尝试运行应用程序作为Android应用程序通过选择运行as-> Android应用程序,但我总是得到这个错误:

I'm using m2e with Eclipse and Android and tried to run the application as "Android Application" by selecting run as->Android application, but I always get this error:


未指定的顶级例外:java.lang.IllegalArgumentException:
已添加:Lorg / hamcrest / BaseDescription;

。 。

UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lorg/hamcrest/BaseDescription;
. . .

[2012-09-08 19:50:41 - net.mydomain.project-TRUNK]转换为
Dalvik格式失败,出现错误1


[2012-09-08 19:50:41 - net.mydomain.project-TRUNK] Conversion to Dalvik format failed with error 1

这是这里的工具R14部分一>。首先,这不能解决,因为我在ADT 20.0.3中有这个问题。其次,我没有这些所谓的_src文件夹。我以前从未在Maven项目中看到过,所以我不知道现在应该怎么做。我甚至没有任何图书馆连接两次。至少我的项目中没有看到。任何想法如何使这个工作?

It's the problem described here in Tools R14 section. First of all, this cannot be fixed because I have this issue in ADT 20.0.3. Secondly, I don't have these so called "_src" folders. I've never seen them in a Maven project before, so I don't know what I should do now. I don't even have any libraries linked twice. At least I don't see some in my project. Any ideas how to get this working?

这是我的pom.xml如果这有帮助:

Here is my pom.xml if this helps:

<?xml version="1.0" encoding="UTF-8"?>
  <project xmlns="http://maven.apache.org/POM/4.0.0"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>net.devgems.android</groupId>
    <artifactId>kurzparkzonewien</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>kurzparkzonewien</name>

    <properties>
        <platform.version>1.6_r2</platform.version>
        <android.sdk.path>/opt/android-sdk-linux</android.sdk.path>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.0.1</version>
        </dependency>
        <!-- Make sure this is below the android dependencies -->
        <dependency>
            <groupId>com.pivotallabs</groupId>
            <artifactId>robolectric</artifactId>
            <version>1.0-RC1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <outputDirectory>target/classes</outputDirectory>
        <testOutputDirectory>target/test-classes</testOutputDirectory>

        <plugins>
            <plugin>
                 <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                    <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                    <resourceDirectory>${project.basedir}/res</resourceDirectory>
                    <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
                    <sdk>
                        <platform>4</platform>
                        <path>${android.sdk.path}</path>
                    </sdk>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
   </project>

我正在使用Eclipse Juno,ADT 20.0.3,m2e 1.1.0。

I'm using Eclipse Juno, ADT 20.0.3, m2e 1.1.0.

推荐答案

我找到了解决方案。这取决于JUnit版本,因为JUnit 4.10添加了JUnit库和hamcrest jar库,尽管JUnit 4.10已经包含所有的hamcrest类,所以hamcrest存在两次。如果我切换回JUnit 4.8.1,它不会添加hamcrest作为库,错误消失。

I found the solution. It depends on the JUnit version, because JUnit 4.10 adds JUnit library and hamcrest jar library, although JUnit 4.10 already contains all the hamcrest classes, so hamcrest exists twice then. If I switch back to JUnit 4.8.1, it doesn't add hamcrest as library and the error is gone.

这个解决方案实际上是一种解决方法。通常Eclipse Maven插件应该处理这个,但是Hamcrest / JUnit是一个特殊的问题,因为JUnit包括Hamcrest,而不是作为依赖,而是在代码中。

This solution is actually a workaround. Usually the Eclipse Maven plugin should handle this, but Hamcrest/JUnit is a special problem, because JUnit includes Hamcrest, not as dependency, but in code.

这篇关于java.lang.IllegalArgumentException:已添加:Lorg / hamcrest / BaseDescription;转换为Dalvik格式失败,出现错误1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆