故障处理“;javax/xml/xmlstants.class“;

故障处理“;javax/xml/xmlstants.class“;,java,android,Java,Android,我正在启动一个新的Android项目。该项目引用了一个第三方JAR,该JAR又引用了4个其他JAR: ws-commons-java5-1.0.1.jar ws-commons-util-1.0.2.jar xmlrpc-client-3.1.3.jar xmlrpc-common-3.1.3.jar 据我所知,我认为这4个JAR是我认为的标准Java类。无论如何,我的构建路径中有这五个jar(上面的4个+1个第三方jar)。当我尝试运行Android应用程序时,我得到: Dx troubl

我正在启动一个新的Android项目。该项目引用了一个第三方JAR,该JAR又引用了4个其他JAR:

ws-commons-java5-1.0.1.jar
ws-commons-util-1.0.2.jar
xmlrpc-client-3.1.3.jar
xmlrpc-common-3.1.3.jar
据我所知,我认为这4个JAR是我认为的标准Java类。无论如何,我的构建路径中有这五个jar(上面的4个+1个第三方jar)。当我尝试运行Android应用程序时,我得到:

Dx 
trouble processing "javax/xml/XMLConstants.class":

Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.

This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.

However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.

If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.

If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.

If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.

[2012-03-21 23:05:05 - MyApp ] Dx 1 error; aborting
[2012-03-21 23:05:05 - MyApp ] Conversion to Dalvik format failed with error 1
我不知道该怎么办。这就像是在问我是否要建立一个核心库,而我不是。我只是想在我的项目中使用这些罐子。在我的项目中有没有其他方法可以引用这些JAR?这个错误听起来好像我的项目有一天会随机停止为某人工作


这一切都很令人困惑。关于如何正确进行的任何线索?

您的问题是ws-commons-java5-1.0.1.jar是核心Java库的一部分的重新实现。Android不允许您替换核心库


好消息是ws-commons-java5应该只对Java1.4或更低版本是必需的,Android包含了它所取代的Java1.5中的类。因此,您应该能够从您的项目中删除此文件,并且它应该可以工作…

在SO上有一些类似的问题报告(与其他类相同,但消息类型相同),并且隐藏在一条注释中,指向外部站点上解决方案的指针:


嗯,好吧,我没有考虑过。我会试试看,然后回来汇报。谢谢