I am trying to build an android project with maven, but maven doesn't like the Qname class:
[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.
This problem only started occurring when I brought in a separate apklib file:
<dependency>
<groupId>cocos2d_android</groupId>
<artifactId>cocos2d_android</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
It appears the QName
class only appears in my dependencies in the xpp3 jarfile which, as far as I can tell, only appears in this dependency:
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${android-version}</version>
</dependency>
I tried using the exclusion tag to get Maven to play nice with it, but the xmlpullparser class is being used in code in my project so I get a class not found error when I exclude it.
For completeness, here's my full dependency list:
<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>
I've seen other questions talking about this being imported in other google data apis, but obviously I'm not using those here - can someone explain why Maven is complaining about this class that's only part of the main google android apis?
In case you reference com.google.android:android as dependency, do not forget to set provided scope - otherwise plugin will try to pack it into resulting apk
provided
was the default. This did it. Thanks - Bry M. 2012-04-04 14:54
You cannot build Android applications that import JAR files that use java.* or javax.* packages. The cocos2d_android dependency either contains a copy of this class or includes a transitive dependency that does. You might need to exclude the javax.xml.namespace.QName class using a Maven dependency exclusion.