android simple-xml,使用Maven构建Android项目-dexer在simple-xml依赖项上失败

我有绝对空的Android项目生成

mvn archetype:generate -DarchetypeArtifactId=android-quickstart .......

它构建良好,部署合理,运行良好.问题是,当我添加

org.simpleframework

simple-xml

2.6.2

依赖,构建失败,

[INFO] --- android-maven-plugin:3.0.0:dex (default-dex) @ whoops-android-app1 ---

[INFO] C:\Program Files\Java\jdk1.7.0\jre\bin\java [-jar, D:\android-sdk\platform-tools\lib\dx.jar, --dex, --output=D:\whoops\xxx\whoops-android-app1\target\classes.dex, C:\Users\loki2302\.m2\repository\xpp3\xpp3\1.1.4c\xpp3-1.1.4c.jar, C:\Users\loki2302\.m2\repository\org\simpleframework\simple-xml\2.6.2\simple-xml-2.6.2.jar, C:\Users\loki2302\.m2\repository\stax\stax\1.2.0\stax-1.2.0.jar, C:\Users\loki2302\.m2\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar, D:\whoops\xxx\whoops-android-app1\target\classes]

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

[INFO]

[INFO] This is often due to inadvertently including a core library file

[INFO] in your application's project, when using an IDE (such as

[INFO] Eclipse). If you are sure you're not intentionally defining a

[INFO] core class, then this is the most likely explanation of what's

[INFO] going on.

[INFO]

[INFO] However, you might actually be trying to define a class in a core

[INFO] namespace, the source of which you may have taken, for example,

[INFO] from a non-Android virtual machine project. This will most

[INFO] assuredly not work. At a minimum, it jeopardizes the

[INFO] compatibility of your app with future versions of the platform.

[INFO] It is also often of questionable legality.

[INFO]

[INFO] If you really intend to build a core library -- which is only

[INFO] appropriate as part of creating a full virtual machine

[INFO] distribution, as opposed to compiling an application -- then use

[INFO] the "--core-library" option to suppress this error message.

[INFO]

[INFO] If you go ahead and use "--core-library" but are in fact

[INFO] building an application, then be forewarned that your application

[INFO] will still fail to build or run, at some point. Please be

[INFO] prepared for angry customers who find, for example, that your

[INFO] application ceases to function once they upgrade their operating

[INFO] system. You will be to blame for this problem.

[INFO]

[INFO] If you are legitimately using some code that happens to be in a

[INFO] core package, then the easiest safe alternative you have is to

[INFO] repackage that code. That is, move the classes in question into

[INFO] your own package namespace. This means that they will never be in

[INFO] conflict with core system classes. JarJar is a tool that may help

[INFO] you in this endeavor. If you find that you cannot do this, then

[INFO] that is an indication that the path you are on will ultimately

[INFO] lead to pain, suffering, grief, and lamentation.

[INFO]

[INFO] 1 error; aborting

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 2.711s

[INFO] Finished at: Tue Dec 13 12:31:23 MSK 2011

[INFO] Final Memory: 18M/178M

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.0.0:dex (default-dex) on project whoops-android-app1: MojoExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C ""C:\Program Files\Java\jdk1.7.0\jre\bin\java" -jar D:\android-sdk\platform-tools\lib\dx.jar --dex --output=D:\whoops\xxx\whoops-android-app1\target\classes.dex C:\Users\loki2302\.m2\repository\xpp3\xpp3\1.1.4c\xpp3-1.1.4c.jar C:\Users\loki2302\.m2\repository\org\simpleframework\simple-xml\2.6.2\simple-xml-2.6.2.jar C:\Users\loki2302\.m2\repository\stax\stax\1.2.0\stax-1.2.0.jar C:\Users\loki2302\.m2\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar D:\whoops\xxx\whoops-android-app1\target\classes", Result = 1 -> [Help 1]

删除此依赖关系可修复构建.这是我的mvn –version:

Apache Maven 3.0.3 (r1075438; 2011-02-28 20:31:09+0300)

Maven home: D:\apache-maven-3.0.3\bin\..

Java version: 1.7.0, vendor: Oracle Corporation

Java home: C:\Program Files\Java\jdk1.7.0\jre

Default locale: en_US, platform encoding: Cp1251

OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

这是我的pom.xml:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

4.0.0

com.whoops.android

whoops-android-app1

1.0-SNAPSHOT

apk

whoops-android-app1

com.google.android

android

2.1.2

provided

org.simpleframework

simple-xml

2.6.2

com.jayway.maven.plugins.android.generation2

android-maven-plugin

3.0.0

${project.basedir}/AndroidManifest.xml

${project.basedir}/assets

${project.basedir}/res

${project.basedir}/src/main/native

7

true

true

true

maven-compiler-plugin

2.3.2

1.6

1.6

之前尝试过Maven 2和Maven-android-plugin 2. *-结果是相同的.仅对simple-xml依赖项失败.在禁用simple-xml的情况下启用codegist-crest效果很好.仅当我使用simple-xml时才会发生这种情况.

我还尝试了在没有maven(Eclipse)的情况下进行同样的操作-在这种情况下,即使我的构建路径上具有simple-xml,一切都可以正常工作.

有任何想法吗?

解决方法:

这里的问题是simple-xml或更可能是其依赖项之一已经在保留的java.*或javax.*名称空间中定义了一个或多个类.在Android平台上不允许这样做.虽然,我不确定为什么这会在Eclipse中起作用.该库是否可能在构建路径上,但未包含在最终编译的APK中?

由于Android平台提供了许多与XML相关的软件包,因此您可能不需要simple-xml:

更新:

标签:maven,android

来源: https://codeday.me/bug/20191101/1987261.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值