环境:开发 android
eclipse + maven
在使用 maven 开发 android 中
<dependencies>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.4-beta1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4-beta1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
编译中出现
Unable to execute dex: Multiple dex files define Lorg/apache/commons/logging/Log;
Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/apache/commons/logging/Log;
在android 更目录中 使用 mvn dependency:tree
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for DefinitiveGuide:DefinitiveGuide:apk:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for com.jayway.maven.plugins.android.generation2:maven-android-plugin is missing. @ line 55, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 47, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DefinitiveGuide 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ DefinitiveGuide ---
[INFO] DefinitiveGuide:DefinitiveGuide:apk:0.0.1-SNAPSHOT
[INFO] +- net.lingala.zip4j:zip4j:jar:1.3.2:compile
[INFO] +- org.apache.httpcomponents:httpmime:jar:4.4-beta1:compile
[INFO] | \- org.apache.httpcomponents:httpclient:jar:4.4-beta1:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] +- org.apache.httpcomponents:httpcore:jar:4.4-beta1:compile
[INFO] +- commons-codec:commons-codec:jar:1.10:compile
[INFO] \- com.alibaba:fastjson:jar:1.2.3:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.021 s
[INFO] Finished at: 2015-01-10T13:12:11+08:00
[INFO] Final Memory: 19M/219M
[INFO] ------------------------------------------------------------------------
修改 pom.xml 文件
<dependencies>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.4-beta1</version>
<span style="color:#FF6666;"><!-- 去掉重复 jar 包 -->
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions></span>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4-beta1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
编译顺利完成。运行也OK。