Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

java - 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...