eur*_*a19 6 java xml android android-gradle-plugin
我最近将我的android项目从maven迁移到了gradle.这样做之后,我无法在我的java文件中导入javax.xml.bind.当项目在maven时(这可能是因为它是一个java项目而不是一个android项目),这很好用.
我在网上搜索并发现JVM支持javax.xml.bind,但DVM(Dalvik虚拟机)却没有.所以我尝试在build.gradle文件中添加此库作为依赖项,如下所示:
dependencies {
....
compile 'javax.xml.bind:jaxb-api:2.2.x'
....
}
Run Code Online (Sandbox Code Playgroud)
当我在上述更改后构建我的应用程序时,我收到以下构建错误:
:dexDebug
Unknown source file : trouble processing "javax/xml/bind/annotation/XmlID.class":
Unknown source file : Ill-advised or mistaken usage of a core class (java.* or javax.*)
Unknown source file : when not building a core library.
Unknown source file : This is often due to inadvertently including a core library file
Unknown source file : in your application's project, when using an IDE (such as
Unknown source file : Eclipse). If you are sure you're not intentionally defining a
Unknown source file : core class, then this is the most likely explanation of what's
Unknown source file : going on.
Unknown source file : However, you might actually be trying to define a class in a core
Unknown source file : namespace, the source of which you may have taken, for example,
Unknown source file : from a non-Android virtual machine project. This will most
Unknown source file : assuredly not work. At a minimum, it jeopardizes the
Unknown source file : compatibility of your app with future versions of the platform.
Unknown source file : It is also often of questionable legality.
Unknown source file : If you really intend to build a core library -- which is only
Unknown source file : appropriate as part of creating a full virtual machine
Unknown source file : distribution, as opposed to compiling an application -- then use
Unknown source file : the "--core-library" option to suppress this error message.
Unknown source file : If you go ahead and use "--core-library" but are in fact
Unknown source file : building an application, then be forewarned that your application
Unknown source file : will still fail to build or run, at some point. Please be
Unknown source file : prepared for angry customers who find, for example, that your
Unknown source file : application ceases to function once they upgrade their operating
Unknown source file : system. You will be to blame for this problem.
Unknown source file : If you are legitimately using some code that happens to be in a
Unknown source file : core package, then the easiest safe alternative you have is to
Unknown source file : repackage that code. That is, move the classes in question into
Unknown source file : your own package namespace. This means that they will never be in
Unknown source file : conflict with core system classes. JarJar is a tool that may help
Unknown source file : you in this endeavor. If you find that you cannot do this, then
Unknown source file : that is an indication that the path you are on will ultimately
Unknown source file : lead to pain, suffering, grief, and lamentation.
Unknown source file : 1 error; aborting
:dexDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
Run Code Online (Sandbox Code Playgroud)
如何成功导入此库?我是android和gradle的初学者所以任何帮助对我来说都很有用:)
小智 0
它发现您的项目正在导入核心类(java.* 或 javax.*)。
您可以使用“JarJar”工具将“javax.xml.bind”名称空间更改为另一个名称空间(例如:“oop.xml.bind”),这样您就可以解决此问题并将其导入为第三方库,您可以避免与核心类使用相同的命名空间。
祝你好运!
归档时间: |
|
查看次数: |
4134 次 |
最近记录: |