gpt4 book ai didi

由于 "unexpected top-level exception"(使用 odata4j 依赖项),Android maven 构建(eclipse)失败

转载 作者:行者123 更新时间:2023-11-29 18:03:37 24 4
gpt4 key购买 nike

我在构建 android maven 项目时遇到问题(eclipse m2e,maven 的 android)。

“安装”目标恢复为:

[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Ljavax/persistence/Access;
[INFO] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)

我已将以下依赖项添加到项目中:

<dependency>
<groupId>org.odata4j</groupId>
<artifactId>odata4j-jersey</artifactId>
<version>0.7.0</version>
</dependency>

此依赖项还添加了(除其他外)javax.persistence-2.0.0.jar。

所以我认为库被添加了两次?但是如何解决这个问题呢?当我删除依赖项时,项目可以无错误地构建。

这是命令的输出:maven dependency:tree

[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ myapp ---
[INFO] org.subby.android:myapp:apk:0.0.1-SNAPSHOT
[INFO] +- com.google.android:android:jar:4.1.1.4:provided
[INFO] | +- commons-logging:commons-logging:jar:1.1.1:provided
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.0.1:provided
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.0.1:provided
[INFO] | | +- (commons-logging:commons-logging:jar:1.1.1:provided - omitted for duplicate)
[INFO] | | \- commons-codec:commons-codec:jar:1.3:provided
[INFO] | +- org.khronos:opengl-api:jar:gl1.1-android-2.1_r1:provided
[INFO] | +- xerces:xmlParserAPIs:jar:2.6.2:provided
[INFO] | +- xpp3:xpp3:jar:1.1.4c:provided
[INFO] | \- org.json:json:jar:20080701:provided
[INFO] \- org.odata4j:odata4j-jersey:jar:0.7.0:compile
[INFO] +- org.odata4j:odata4j-core:jar:0.7.0:compile
[INFO] | +- org.core4j:core4j:jar:0.5:compile
[INFO] | +- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] | +- org.eclipse.persistence:javax.persistence:jar:2.0.0:compile
[INFO] | +- org.eclipse.persistence:eclipselink:jar:2.1.2:compile
[INFO] | \- joda-time:joda-time:jar:1.6:compile
[INFO] +- com.sun.jersey:jersey-core:jar:1.1.5:compile
[INFO] | \- (javax.ws.rs:jsr311-api:jar:1.1.1:compile - omitted for duplicate)
[INFO] +- com.sun.jersey:jersey-server:jar:1.1.5:compile
[INFO] | +- (com.sun.jersey:jersey-core:jar:1.1.5:compile - omitted for duplicate)
[INFO] | \- asm:asm:jar:3.1:compile
[INFO] \- com.sun.jersey:jersey-client:jar:1.1.5:compile
[INFO] \- (com.sun.jersey:jersey-core:jar:1.1.5:compile - omitted for duplicate)

我做错了什么吗?我对 maven 还是很陌生。

谢谢!

最佳答案

发生这种情况是因为您的构建中有重复的类。如果您的 Eclipse 类路径包含多个具有相同名称/包的类,ADT 将抛出 s。

我建议运行 mvn dependency:tree 在那里你会得到全貌

[INFO] +- com.sun.jersey:jersey:jar:0.8-ea-SNAPSHOT:compil
[INFO] | +- javax.ws.rs:jsr311-api:jar:0.8:compile
[INFO] | \- asm:asm:jar:3.1:compile
[INFO] \- com.sun.jersey:jersey-client:jar:1.9.1:test
[INFO] \- com.sun.jersey:jersey-core:jar:1.9.1:test

重复项是从 odata4j-jersey 传递过来的一些依赖项。为了修复它们,您可以在重复项上添加类似这样的内容:

<project>
...
<dependencies>
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

关于由于 "unexpected top-level exception"(使用 odata4j 依赖项),Android maven 构建(eclipse)失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14502897/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com