我正在尝试用maven构建一个android项目,但是maven不喜欢Qname类:
[INFO] /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java [-Xms256m, -Xmx512m, -jar, /Users/bry_m/code/android-sdk-macosx/platform-tools/lib/dx.jar, --dex, --output=/Users/bry_m/code/eclipse_workspace_2mar2012/maven.1331582410730/trunk/target/classes.dex, /Users/bry_m/code/eclipse_workspace_2mar2012/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/org/springframework/android/spring-android-rest-template/1.0.0.M2/spring-android-rest-template-1.0.0.M2.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/org/codehaus/jackson/jackson-mapper-asl/1.6.4/jackson-mapper-asl-1.6.4.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/org/json/json/20080701/json-20080701.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/com/google/android/android/2.3.1/android-2.3.1.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/commons-codec/commons-codec/1.3/commons-codec-1.3.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/org/codehaus/jackson/jackson-jaxrs/1.6.4/jackson-jaxrs-1.6.4.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/maven.1331582410730/trunk/target/classes, /Users/bry_m/code/eclipse_workspace_2mar2012/org/khronos/opengl-api/gl1.1-android-2.1_r1/opengl-api-gl1.1-android-2.1_r1.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/org/codehaus/jackson/jackson-core-asl/1.6.4/jackson-core-asl-1.6.4.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/org/twitter4j/twitter4j-core/2.2.6-SNAPSHOT/twitter4j-core-2.2.6-SNAPSHOT.jar, /Users/bry_m/code/eclipse_workspace_2mar2012/cocos2d_android/cocos2d_android/1.0.0-SNAPSHOT/cocos2d_android-1.0.0-SNAPSHOT.apklib, /Users/bry_m/code/eclipse_workspace_2mar2012/com/codeslap/android-facebook/1.5/android-facebook-1.5.jar]
[INFO]
[INFO] trouble processing "javax/xml/namespace/QName.class":
[INFO]
[INFO] Ill-advised or mistaken usage of a core class (java.* or javax.*)
[INFO] when not building a core library.
当我引入一个单独的apklib文件时,才会出现此问题:
<dependency>
<groupId>cocos2d_android</groupId>
<artifactId>cocos2d_android</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
QName
类似乎只出现在xpp3 jarfile中的依赖项中,据我所知,它只出现在这个依赖项中:
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${android-version}</version>
</dependency>
我尝试使用排除标记让Maven玩得很好,但xmlpullparser类正在我的项目中的代码中使用,所以当我排除它时,我得到一个类找不到错误。
为了完整性,这是我的完整依赖列表:
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${android-version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>${jacksonVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-rest-template</artifactId>
<version>${spring-android-version}</version>
</dependency>
<dependency>
<groupId>com.codeslap</groupId>
<artifactId>android-facebook</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>cocos2d_android</groupId>
<artifactId>cocos2d_android</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[2.2,)</version>
</dependency>
</dependencies>
我已经看到其他问题正在谈论这是在其他谷歌数据apis中导入,但显然我不在这里使用 - 有人可以解释为什么Maven抱怨这个类只是主要谷歌android apis的一部分?
答案 0 :(得分:1)
您无法构建导入使用java。*或javax。*包的JAR文件的Android应用程序。 cocos2d_android依赖项包含此类的副本或包含传递依赖项。您可能需要使用Maven dependency exclusion排除javax.xml.namespace.QName类。
答案 1 :(得分:1)
如果您将com.google.android:android作为依赖项引用,请不要忘记设置提供的范围 - 否则插件会尝试将其打包到生成的apk