1

I have an Android project with Robolectric.

My application related classes are placed in src/main/java and test related classes in src/test/java.

I have these test dependencies in my pom.xml

        <dependency>
            <groupId>org.robolectric</groupId>
            <artifactId>robolectric</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

When building and deploying from console with mvn package android:deploy everything is ok. Problem occurs when launching project from Eclipse (Juno).

[2013-03-24 12:27:26 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/apache/maven/artifact/Artifact;
[2013-03-24 12:27:26 - my-app] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/apache/maven/artifact/Artifact;

It appears that dependencies that are required for Robolectric only are included. What am I doing wrong?

4

3 回答 3

5

在文件夹 bin/dexedlibs 你有一个重复的 jar

  1. 去掉它
  2. 大扫除
  3. 重试
于 2013-03-24T10:49:51.603 回答
2

经过一番调查,这似乎是与 m2e-android 相关的问题

于 2013-04-08T17:52:25.727 回答
1

我曾经遇到过同样的错误。最后,我发现它是由两次包含 MoPubView 的 jar 引起的:

- On the one hand, I imported the MoPubView project via Eclipse Menu function "File | Import";  

 -> then right click my project, select "Properties"; 
 -> In the left bar, select "android";
 -> In the "Library" section at the right, press [Add] button...  

- On the other hand, I copied the mopub-sdk.jar to the /libs folder of my project. 

我删除了后者。解决了。

于 2013-05-24T00:20:26.347 回答