安卓:错误包括其中引用的javax核心类/重新包装的依赖核心、错误、javax

2023-09-04 08:32:09 作者:燃烧吧少年

我正在使用Maven作为构建工具,一个Android应用程序。我设法正确设置evertyhing了(Maven依赖出口的APK等),但我有一个剩下的问题是让我疯了。

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.

我想包括在 simpleframework的XML解析器的定义在我的POM文件如下依赖:

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>

当我发出 MVN安装的项目,我得到以下错误(截断):

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

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

我知道,从简单的XML解析器引用这些使用javax类错误的结果,但我还没有找到一个解决办法(设定--core库标志是没有用的)。

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).

目前,我想要重新包装与Maven的jarjar-pluging的依赖,但这似乎并没有擦出火花。

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!

推荐答案

定义你的简单的XML depedency是这样的:

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>