不构建核心库时对核心类(java。*或javax。*)的不良使用或错误使用 [英] Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library

查看:125
本文介绍了不构建核心库时对核心类(java。*或javax。*)的不良使用或错误使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

清理项目时出现以下错误:

When I clean my project I get the following error:

[2011-10-05 13:47:53 - The Basics] Dx 
trouble processing "java/nio/CharBuffer.class":

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

这通常是由于在应用程序项目中无意中包含了核心库文件
使用IDE(例如
Eclipse)。如果确定没有故意定义
核心类,那么这是
发生情况的最可能解释。

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.

但是,实际上您可能正在尝试在核心
命名空间中定义一个类,该类的来源可能已从非Android虚拟机项目中获取,例如
。当然,这肯定不会起作用。至少,这会损害您的应用程序与该平台的未来版本的
兼容性。
它的合法性通常也很可疑。

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.

如果您真的打算构建一个核心库,那么在创建过程中只适合
完整的虚拟机
分发,而不是编译应用程序-然后使用
的 --core-library选项来禁止显示此错误消息。

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.

如果继续使用 --core-library,但实际上
正在构建应用程序,则应事先警告您的应用程序
在某些时候仍将无法构建或运行。请准备好为愤怒的客户准备的
,例如,发现您的
应用程序一旦升级了运行中的
系统就会停止运行。

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.

如果您合法使用的某些代码恰好位于
核心软件包中,那么最安全的替代方法就是您必须将
的代码重新打包。也就是说,将相关类移至您自己的程序包名称空间
中。这意味着它们永远不会与核心系统类发生
冲突。 JarJar是一种工具,可以帮助您完成这项工作。如果您发现自己无法做到这一点,那么
表示您所走的道路最终会导致
导致痛苦,折磨,悲伤和悲伤。

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.

[2011-10-05 13:47:53 - The Basics] Dx 1 error; aborting
[2011-10-05 13:47:53 - The Basics] Conversion to Dalvik format failed with error 1


推荐答案

我遇到了这个问题。我使用Maven构建我的android项目。我的问题是由我的依赖项之一(取决于android jars)引起的。我更新了pom,将android从该依赖项中排除,这为我解决了这个问题。

I had this problem. I use Maven to build my android projects. My problem was caused by one of my dependencies depending on the android jars. I updated my pom to exclude android from that dependency and that solved it for me.

  <dependency>
        <groupId>org.reassembler</groupId>
        <artifactId>synth-android</artifactId>
        <version>2.5.8</version>
        <exclusions>
            <exclusion>
                <artifactId>junit</artifactId>
                <groupId>junit</groupId>
            </exclusion>
            <exclusion>
                <artifactId>android</artifactId>
                <groupId>android</groupId>
            </exclusion>
        </exclusions>
    </dependency>

希望这对某人有帮助,我花了一段时间才弄清楚发生了什么。

Hope this helps someone, it took me a while to figure out what was going on.

这篇关于不构建核心库时对核心类(java。*或javax。*)的不良使用或错误使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆