【问题标题】:Attempted to fix androids "ill-advised or mistaken usage of a core class" went bad试图修复机器人“不明智或错误地使用核心类”失败了
【发布时间】:2013-08-18 11:29:18
【问题描述】:

在尝试根据我在网上看到的内容自行解决此问题后,我仍然无法弄清楚这意味着什么:

[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

我不知道这到底是在告诉我什么,也不知道从哪里开始看。我是否以某种方式递归地包含了一个库?我在 order 和 export 下的构建路径如下:

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  

我自己添加了一个作为外部罐子。我忘记了它需要什么,但如果我删除它,它就不能使用像 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

【问题讨论】:

  • 听起来您对自己的应用程序感到困惑——诸如“我忘记了它需要什么”和“有些奇怪”之类的东西并不令人鼓舞。错误消息非常清楚地表明了有问题的类 (javax.xml.namespace.QName),因此您应该找出包含该类的 jar 文件。
  • 已经有一段时间了,主要是我要说的是为什么它之前而不是现在......我没有改变我正在构建的api级别,一定是我创建了这个在安装了 adt 和 sdk 的 eclipse 上单独安装,而不是全部作为一个包。
  • 嗯,大概你改变了一些东西,但我们不知道你做了什么。无论如何,我已经解释了你应该怎么做才能找出问题所在。
  • 嘿@Co​​dejoy,你​​找到解决方案了吗?
  • 同样的问题,无事可做。无论如何,使用那个javax jar。不知何故,构建正在拉动它,但我没有使用任何东西。很多人似乎都遇到过这种构建 android 应用程序的情况,而且似乎最常见的问题是在 android.jar 中多次添加错误配置的 IDE。因为我是用 gradle 构建的,所以肯定不是那样的。

标签: java android android-emulator


【解决方案1】:

Dalvik JVM 不支持 Oracle JDK 的整个 API。我认为javax.* 包不适用于Android。例如,Android 上没有 Java 的 AWTSwingGraphics2D

根据错误,您的应用似乎正在使用此类:http://docs.oracle.com/javase/7/docs/api/javax/xml/namespace/QName.html

如果您将 IDE 设置为使用 Android SDK 而不是 JDK,则不应发生这种情况。

【讨论】:

  • 我想知道这是从哪里来的,可能是我用于 ormlite-android-4.24.jar 的 ormlite jars。如果我不得不猜测......并且正如上面的海报所暗示的那样,它会告诉我那在哪里。 QName...我不知道如何在 jars 中搜索,我不认为 windows 搜索可以,我想知道 eclipse 是否可以。
  • @Codejoy 不,ORMLite 适用于安卓系统。您还使用哪些其他库?你能在源文件中搜索javax.xml 吗?
  • 让我编辑我的帖子。另外我必须承认我没有使用那些我自己知道的包让我跑下来。不过有两件事,你说我应该将我的 IDE 设置为使用 Android SDK,据我所知,它设置为使用安装了 jre7 的 java 1.7?
  • @Codejoy 我不知道 eclipse,但是 intellij 和 android studio 确实有一个“project sdk”设置,android 是 jdk 之外的一个选项。
  • @Codejoy 应该在某个xml库中,很可能是xmlParserAPIs
【解决方案2】:

如果您使用 Maven 构建,请确保您对 android SDK 的依赖范围为 provided,否则您将收到此消息,因为 DEX 尝试将所有类包含在 android.jar 中。

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

【讨论】:

  • 你有对应的 gradle 吗?
  • 不,抱歉。我尝试使用 gradle 的混乱,但我喜欢我的构建可复制。
  • 我不同意这种说法,并且发现我们的构建非常可重现,但每个构建都有自己的。我建议在它离开 beta 状态后再旋转一次(!),因为它确实将 ANT 从水中吹了出来,并且是 Maven 的超集。
  • 我在 7 年前放弃了 Ant,转而使用 Maven,并且从未使用 Ant 构建 Android 项目。 Gradle 是 Maven 的超集,我不敢苟同,它似乎是相反的。 Gradle 似乎是 Maven 于 2004 年回归的地方,刚刚开始了解这个领域。恕我直言,它还有很长的路要走。
  • Superset 意味着你可以执行 maven 插件并在上面创建 gradle 任务。但是,是的,我们同意还有一段路要走。
【解决方案3】:

我在将项目从 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:jackson-core-asl:1.9.13'。问题解决了。

【讨论】:

    【解决方案4】:

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

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

    从你的依赖中移除(注释掉)这个调用。

    download jar file,包含在libs文件夹中并右键单击Add as library。你应该像雨一样正确。

    【讨论】:

      【解决方案5】:

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

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-05-19
        • 1970-01-01
        • 1970-01-01
        • 2017-04-04
        • 1970-01-01
        • 1970-01-01
        • 2021-12-14
        • 1970-01-01
        相关资源
        最近更新 更多