转换为 Dalvik 格式失败,出现错误 1 ​​- 无法从 Android 编译 ApiDemos 示例

发布于 2024-12-04 19:31:04 字数 1259 浏览 0 评论 0原文

我从 ApiDemo 在 Eclipse Indingo(在 Windows 7 中)中为 API 12 示例代码创建了一个项目。我对 11 和 13 做了同样的事情,得到了如下所述的相同结果。

  1. 如果没有 android-support-v4.jar,这个东西根本无法编译,生成超过 300 个编译错误 - 主要是无法解析某些类。

  2. 将 android-suuport-v4 添加到项目的 libs 目录,然后添加到构建路径后,我能够消除编译错误,但随后开始出现这个我无法解决的讨厌错误。只有当我从构建路径中删除 v4 兼容性 jar 但编译错误又回来时,我才会消失。

这太疯狂了……更加沮丧,因为我在让基本的演示 iPhone 项目工作时从来没有遇到任何问题……

请帮忙……

[2011-09-16 14:06:34 - ApiDemos] Dx 处理“javax/xml/datatype/DatatypeFactory.class”时遇到问题:

核心类(java.* 或 javax.*)的不明智或错误使用 当不构建核心库时。

这通常是由于无意中包含了核心库文件造成的 在您的应用程序项目中,当使用 IDE(例如 蚀)。如果您确定您不是有意定义 核心类,那么这是最有可能的解释 正在进行中。

然而,您实际上可能试图在核心中定义一个类 命名空间,您可能采用的来源,例如, 来自非 Android 虚拟机项目。这将最 肯定不行。至少,它会危及 您的应用程序与平台未来版本的兼容性。 它的合法性也常常受到质疑。

如果你真的打算构建一个核心库——这只是 适合作为创建完整虚拟机的一部分 分发,而不是编译应用程序——然后使用 “--core-library”选项可以抑制此错误消息。

如果您继续使用“--core-library”,但实际上 构建一个应用程序,然后预先警告您的应用程序 在某些时候仍然无法构建或运行。请 为愤怒的客户做好准备,例如,他们发现您的 一旦升级操作,应用程序将停止运行 系统。你将要为这个问题负责。

如果您合法地使用恰好位于 core 包,那么你拥有的最简单安全的替代方案是 重新打包该代码。也就是说,将有问题的类移动到 你自己的包命名空间。这意味着他们永远不会在 与核心系统类冲突。 JarJar 是一个可能有帮助的工具 你在这一努力中。如果您发现自己无法做到这一点,那么 这表明你所走的道路最终将 导致痛苦、痛苦、悲伤和哀叹。

[2011-09-16 14:06:34 - ApiDemos] Dx 1 错误;中止 [2011-09-16 14:06:34 - ApiDemos] 转换为 Dalvik 格式失败,错误 1

I created a project from ApiDemo for API 12 sample code in Eclipse Indingo (in Windows 7). I did the same for 11 and 13 with the same results described below.

  1. Without android-support-v4.jar this thing would not compile at all generating over 300 compile errors - mostly about not being able to resolve some classes.

  2. Having added android-suuport-v4 to libs directory of the project and then to the build path I was able to eliminate the compile errors but then started getting this pesky error which I cannot resolve. I will only go away if I remove v4 compatibility jar from build path but then compile errors come back.

This is CRAZY....soooo frustrated even more so since I never had any problems getting basic demo iPhone projects to work....

Please help....

[2011-09-16 14:06:34 - ApiDemos] Dx
trouble processing "javax/xml/datatype/DatatypeFactory.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.

[2011-09-16 14:06:34 - ApiDemos] Dx 1 error; aborting
[2011-09-16 14:06:34 - ApiDemos] Conversion to Dalvik format failed with error 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩动你心 2024-12-11 19:31:04

这可能是因为您在尝试构建演示代码之前没有将 SDK/SDK-tools 更新到最新版本。

This might because you didn't update the SDK/SDK-tools to the latest version before you trying to build the demo code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文