首先,至少有2個帖子存在相同的問題,但這些解決方案不再工作,至少在我的安裝中不起作用。java.lang.IllegalArgumentException:已添加:Lorg/hamcrest/BaseDescription;轉換爲Dalvik格式失敗,出現錯誤1
我使用的Eclipse和Android M2E,並試圖通過選擇Run AS-> Android應用程序來運行該應用程序爲「Android應用程序」,但我總是得到這個錯誤:
UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lorg/hamcrest/BaseDescription;
. . .[2012-09-08 19:50:41 - net.mydomain.project-TRUNK] Conversion to Dalvik format failed with error 1
這是問題描述爲here in Tools R14 section。首先,這是無法修復的,因爲我在ADT 20.0.3中遇到了這個問題。其次,我沒有這些所謂的「_src」文件夾。我以前從未在Maven項目中看到過他們,所以我現在不知道該怎麼做。我甚至沒有任何鏈接庫兩次。至少我在我的項目中看不到一些。任何想法如何得到這個工作?
這裏是我的pom.xml如果這能幫助:
<?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。
現貨!在我的情況下,我試圖使用ActionBarSherlock 4.2.0作爲庫項目,並且將JUnit 4.10作爲依賴項引入到我的項目中!將JUnit從4.10更改爲4.8。1在ActionBarSherlock Library pom.xml中修復了它。非常感謝! –
如果您希望繼續使用4.10,那麼您可以明確排除Hamcrest jar作爲JUnit的傳遞依賴項。這是如何做到這一點的搖籃: instrumentTestCompile( '的JUnit:JUnit的:4.10'){ 排除組: 'org.hamcrest' } 看到這裏Maven的等效: HTTP://行家。 apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html – Brendan