Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm working on an Android app using Maven as the build tool. I managed to set evertyhing up correctly (maven dependencies are exported to the apk etc.), however I have one remaining problem which is driving me crazy.

I want to include a dependency on simpleframework's xml parser defined as follows in my POM file:

<dependency>
    <groupId>org.simpleframework</groupId> 
    <artifactId>simple-xml</artifactId>
    <version>2.5.3</version>
</dependency>

When I issue mvn install on the project, I get the following error (truncated):

trouble processing "javax/xml/namespace/NameSpaceContext.class" ...

I know the error results from the simple xml parser referencing these javax-classes, however I haven't found a solution yet (setting the --core-library flag is of no use).

I'm currently trying to repack the dependency with the maven-jarjar-pluging but this doesn't seem to work either.

Can anyone help me out with this? Many, many thanks in advance!

like image 843
thomaux Avatar asked May 11 '11 13:05

thomaux


1 Answers

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>
like image 111
Marcin Jancewicz Avatar answered Oct 02 '22 16:10

Marcin Jancewicz