Android: error including/repacking dependencies which reference javax core classes

梦想的初衷 提交于 2019-11-29 03:41:29

Define your simple-xml depedency like this :

<dependency>
    <groupId>org.simpleframework</groupId>
    <artifactId>simple-xml</artifactId>
    <version>2.6.1</version>
    <exclusions>
        <!-- StAX is not available on Android -->
        <exclusion>
            <artifactId>stax</artifactId>
            <groupId>stax</groupId>
        </exclusion>
        <exclusion>
            <artifactId>stax-api</artifactId>
            <groupId>stax</groupId>
        </exclusion>
        <!-- Provided by Android -->
        <exclusion>
            <artifactId>xpp3</artifactId>
            <groupId>xpp3</groupId>
        </exclusion>
    </exclusions>
</dependency>
barryku

I use android-maven-plugin, and adding <coreLibrary>true</coreLibrary> to the <configuration> tag of the plugin in the POM works for me. However, there's a bug: https://github.com/jayway/maven-android-plugin/pull/34, that you need to include to fix the plugin you are using, since the bug won't be fixed until 3.0. Here's how I got it working for me using 2.9.0-SNAPSHOT.

  1. add a pluginRepository pointing to http:// oss.sonatype.org/content/repositories/jayway-snapshots/ to get 2.9.0-SNAPSHOT
  2. update your plugin version to use 2.9.0-SNAPSHOT and add <coreLibrary>true</coreLibrary> to pom.xml
  3. get the fix: git clone https://github.com/kevinpotgieter/maven-android-plugin.git
  4. remove src/test/java/com: so the test won't fail
  5. mvn package
  6. copy it and overwrite your local maven cache in .m2 (You may need to remove your plugin repository yours gets overwritten every time.)

Step 3-6 won't be necessary after the fix gets into 2.9.0-SNAPSHOT.


Update July 2010: 2.9.0-beta-4 has the fix, so you don't need the above workaround if you use 2.9.0-beta-4 or later. I tested 2.9.0-beta-5 which worked just fine.

Spring Android uses Maven to integrate Simple. Take a look at the following URL, it should provide pointers on how to get Maven working with Simple.

http://static.springsource.org/spring-android/docs/1.0.x/reference/html/rest-template.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!