问题 尝试修复机器人“不明智或错误地使用核心课程”变坏了


在尝试通过我在网络上看到的自己解决这个问题后,我仍然无法弄清楚这意味着什么:

[2013-08-15 23:58:27 - StudioTab] Dx 
trouble processing "javax/xml/namespace/QName.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.

[2013-08-15 23:58:27 - StudioTab] Dx 1 error; aborting
[2013-08-15 23:58:27 - StudioTab] Conversion to Dalvik format failed with error 1

我不知道这是什么告诉我或从哪里开始看。我是否以某种方式递归地包括一个图书馆?我在订单和导出下的构建路径如下:

Google APIs [Android 3.0]
Android Dependencies
   annotations.jar
Android Private Libraries
    A ton of jars for various functionality i need: CSV writing, talking to the           google calendar somehow...etc...etc.  They are jars I found on the net, not ripped from another project but found to solve problems i.e. how to access google calendar from the device and read/write to it etc...  is this where my problem lies? I can provide a complete list of the jars I am using here.
android-support-v4.jar  

我自己添加了一个外部jar。我忘了它需要它但是如果我删除它就不能使用像FragmentActivity这样奇怪的东西。

那么我在哪里开始看起来如此,我可以再次选择这个项目...让它在模拟器上进行编译和运行。

LIBS文件夹如下:          驱动器D中的卷是LargeWorkDisk          卷序列号为206C-D951

     Directory of D:\Programming\StudioTab\libs

    08/16/2013  12:39 AM    <DIR>          .
    08/16/2013  12:39 AM    <DIR>          ..
    08/15/2013  09:45 PM         1,700,072 android-1.5_r4-sources.jar
    08/15/2013  09:45 PM         2,136,034 android-1.5_r4.jar
    08/15/2013  09:45 PM            55,191 commons-codec-1.3-sources.jar
    08/15/2013  09:45 PM            46,725 commons-codec-1.3.jar
    08/15/2013  09:45 PM            74,976 commons-logging-1.1.1-sources.jar
    08/15/2013  09:45 PM            60,686 commons-logging-1.1.1.jar
    08/15/2013  09:45 PM            53,983 google-api-client-1.5.0-beta-sources.jar
    08/15/2013  09:45 PM            44,653 google-api-client-1.5.0-beta.jar
    08/15/2013  09:45 PM            13,356 google-api-client-extensions-1.5.0-beta-sources.jar
    08/15/2013  09:45 PM            15,276 google-api-client-extensions-1.5.0-beta.jar
    08/15/2013  09:45 PM             3,459 google-api-client-extensions-android2-1.5.0-beta-sources.jar
    08/15/2013  09:45 PM             4,556 google-api-client-extensions-android2-1.5.0-beta.jar
    08/15/2013  09:45 PM           309,295 google-collections-1.0-sources.jar
    08/15/2013  09:45 PM           639,592 google-collections-1.0.jar
    08/15/2013  09:45 PM           188,771 google-http-client-1.5.0-beta-sources.jar
    08/15/2013  09:45 PM           196,915 google-http-client-1.5.0-beta.jar
    08/15/2013  09:45 PM             6,433 google-http-client-extensions-1.5.0-beta-sources.jar
    08/15/2013  09:45 PM             7,807 google-http-client-extensions-1.5.0-beta.jar
    08/15/2013  09:45 PM             3,021 google-http-client-extensions-android2-1.5.0-beta-sources.jar
    08/15/2013  09:45 PM             3,854 google-http-client-extensions-android2-1.5.0-beta.jar
    08/15/2013  09:45 PM             6,638 google-http-client-extensions-android3-1.5.0-beta-sources.jar
    08/15/2013  09:45 PM            10,418 google-http-client-extensions-android3-1.5.0-beta.jar
    08/15/2013  09:45 PM            35,765 google-oauth-client-1.5.0-beta-sources.jar
    08/15/2013  09:45 PM            34,394 google-oauth-client-1.5.0-beta.jar
    08/15/2013  09:45 PM            38,030 google-oauth-client-extensions-1.5.0-beta-sources.jar
    08/15/2013  09:45 PM            48,289 google-oauth-client-extensions-1.5.0-beta.jar
    08/15/2013  09:45 PM           140,057 gson-1.6-sources.jar
    08/15/2013  09:45 PM           164,984 gson-1.6.jar
    08/15/2013  09:45 PM           640,031 guava-r09-sources.jar
    08/15/2013  09:45 PM         1,143,921 guava-r09.jar
    08/15/2013  09:45 PM           390,195 httpclient-4.0.3-sources.jar
    08/15/2013  09:45 PM           292,893 httpclient-4.0.3.jar
    08/15/2013  09:45 PM           291,844 httpcore-4.0.1-sources.jar
    08/15/2013  09:45 PM           172,888 httpcore-4.0.1.jar
    08/15/2013  09:45 PM           200,880 jackson-core-asl-1.6.7-sources.jar
    08/15/2013  09:45 PM           201,086 jackson-core-asl-1.6.7.jar
    08/15/2013  09:45 PM           283,945 jdo2-api-2.3-eb-sources.jar
    08/15/2013  09:45 PM           192,820 jdo2-api-2.3-eb.jar
    08/15/2013  09:45 PM           476,722 joda-time-1.6-sources.jar
    08/15/2013  09:45 PM           534,827 joda-time-1.6.jar
    08/15/2013  09:45 PM            39,665 jsontoken-1.0-sources.jar
    08/15/2013  09:45 PM            37,877 jsontoken-1.0.jar
    08/15/2013  09:45 PM            33,015 jsr305-1.3.9.jar
    08/15/2013  09:45 PM           147,086 junit-4.8.2-sources.jar
    08/15/2013  09:45 PM           237,344 junit-4.8.2.jar
    08/16/2013  12:39 AM                 0 libsdir.txt
    08/15/2013  09:45 PM            11,358 LICENSE
    08/15/2013  09:45 PM            14,146 opencsv-2.3.jar
    08/15/2013  09:45 PM            12,986 opengl-api-gl1.1-android-2.1_r1-sources.jar
    08/15/2013  09:45 PM            18,492 opengl-api-gl1.1-android-2.1_r1.jar
    08/15/2013  09:45 PM           125,968 ormlite-android-4.24-javadoc.jar
    08/15/2013  09:45 PM            22,285 ormlite-android-4.24-sources.jar
    08/15/2013  09:45 PM            32,707 ormlite-android-4.24.jar
    08/15/2013  09:45 PM           216,486 ormlite-core-4.24.jar
    08/15/2013  09:45 PM           140,718 protobuf-java-2.2.0-sources.jar
    08/15/2013  09:45 PM           320,306 protobuf-java-2.2.0.jar
    08/15/2013  09:45 PM               501 readme.html
    08/15/2013  09:45 PM           158,114 servlet-api-2.5-sources.jar
    08/15/2013  09:45 PM           105,112 servlet-api-2.5.jar
    08/15/2013  09:45 PM            25,014 transaction-api-1.1-sources.jar
    08/15/2013  09:45 PM            15,071 transaction-api-1.1.jar
    08/15/2013  09:45 PM           124,724 xmlParserAPIs-2.6.2.jar
    08/15/2013  09:45 PM           128,334 xpp3-1.1.4c-sources.jar
    08/15/2013  09:45 PM           120,069 xpp3-1.1.4c.jar
                  64 File(s)     12,952,660 bytes
                   2 Dir(s)  2,057,125,945,344 bytes free

3563
2017-08-16 06:08


起源

听起来你对自己的应用程序感到困惑 - 诸如“我忘记它需要它”和“某些奇怪的东西”之类的东西并不令人鼓舞。错误消息是 非常 明确有问题的课程(javax.xml.namespace.QName所以你应该找出包含哪个jar文件。 - Jon Skeet
它已经有一段时间了,主要是我说的是为什么它之前工作而不是现在......我没有改变我构建的api级别,必须是我在安装了adt的eclipse上创建了这个sdk单独安装,而不是全部作为一个包。 - Codejoy
很可能你改变了一些东西,但我们不知道你做了什么。无论如何,我已经解释了你应该做些什么来弄清楚什么是错的。 - Jon Skeet
嘿@Codejoy,你​​找到了解决方案吗? - Joshua Pinter
同样的问题,无所事事。无论如何,使用那个javax jar。不知怎的,构建正在拉动它,但我没有使用它。很多人似乎遇到了这个构建Android应用程序,似乎最常见的问题是多次在android.jar中添加错误配置的IDE。因为我用gradle建造它当然不是那样的。 - RichieHH


答案:


Dalvik JVM不支持Oracle JDK的整个API。我认为 javax.* 软件包不适用于Android。例如,没有 AWT 要么 Swing 要么 Graphics2D Android上的Java。

从错误中,看起来您的应用程序正在使用此类: http://docs.oracle.com/javase/7/docs/api/javax/xml/namespace/QName.html

这不应该发生如果您将IDE设置为使用Android SDK而不是JDK。


5
2017-08-16 06:15



我想知道它来自哪里,它可能是我用于ormlite-android-4.24.jar的ormlite罐子。如果我不得不猜测...并且正如上面的海报建议它告诉我它在哪里。 QName ...我不知道如何在罐子里面搜索,我不认为windows搜索是不是我想知道是否有日食。 - Codejoy
@Codejoy不, ORMLite 是为了Android。您还在使用其他哪些库?你能搜索一下吗? javax.xml 在源文件? - S.D.
让我编辑我的帖子。此外,我必须承认我没有使用我知道自己的那些包让我把它搞砸了。但有两件事,你说我应该把我的IDE设置为使用Android SDK,据我所知,它设置为使用安装了jre7的java 1.7? - Codejoy
@Codejoy我不知道eclipse,但intellij和android studio确实有一个“项目sdk”设置,而android是一个除了jdk之外的选项。 - S.D.
@Codejoy它应该位于其中一个xml库中,最有可能 xmlParserAPIs。 - S.D.


如果您使用Maven进行构建,请确保您对Android SDK的依赖性具有范围 provided,否则你会得到这条消息,因为DEX试图包含android.jar中的所有类。

  <dependency>
      <groupId>android</groupId>
      <artifactId>android</artifactId>
      <version>4.4.2_r3</version>
      <scope>provided</scope>
  </dependency>

5
2017-07-27 22:53



你有同等的gradle吗? - MLProgrammer-CiM
不,对不起我试图使用gradle的混乱,但我喜欢我的构建repdocible。 - William
我不同意这种说法,并且发现我们的构建非常可重复,但每个都是自己的。一旦它离开β状态(!),我会建议给它第二次旋转,因为它确实将ANT从水中吹出,并且是Maven的超集。 - MLProgrammer-CiM
7年前,我为Maven抛弃了Ant,并且从未使用Ant来构建Android项目。我不同意Gradle是Maven的超集,它似乎是另一种方式。 Gradle似乎是Maven在2004年回归的地方,刚刚开始了解这个空间。恕我直言,它还有很长的路要走。 - William
Superset在某种意义上说你可以执行maven插件并在顶部创建gradle任务。但是,是的,我们同意还有很长的路要走。 - MLProgrammer-CiM


我在将项目从Eclipse迁移到Android Studio时,通过选择一组备用依赖项来解决类似的问题。最初我使用springframework.web和javax.xml.transform来使我的代码通过构建。但该应用程序在运行时立即中止“不明智”错误。然后我用'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE','org.codehaus.jackson:jackson-mapper-asl:1.9.13'和'org替换了这两个依赖项。 codehaus.jackson:杰克逊核心 - 翔升:1.9.13' 。问题解决了。


0
2018-05-11 23:41





由于一些用户询问gradle: 在Android Studio中,您可能正在从gradle构建中引用库,就像这样(让我们说 javax.annotation):

compile 'javax.annotation:jsr250-api:1.0'

从依赖项中删除(注释掉)此调用。

下载jar文件, 包括 libs 文件夹并右键单击 Add as library。雨天你应该是正确的。


0
2018-04-21 19:11





我遇到了类似的抱怨。事实证明我的外部库与android SDK中的类相同。

所以我的决心是使用自定义SDK而不是android SDK。

为此,请执行以下步骤: o A,在local.properties中更改目录'sdk.dir' o B,“与SDK文件同步项目”。该按钮应该能够位于工具栏上。在弹出窗口中,选择“project SDK”。 o它可能会要求下载平台构建工具(取决于build.gradle文件中的定义。例如,在buildToolsVersion的字段中,值为23.0.3.Android studio可能会要求获得下载权限。允许下载。 o Android studio应该能够编译和构建APK。


0
2018-06-01 18:28