java Android SDK 中的 dx.jar 是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10456265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 01:06:56  来源:igfitidea点击:

What is dx.jar in the Android SDKs?

javaandroidintellij-idea

提问by user604713

What is the purpose of the dx.jar file that I see in some of Android SDK versions that I've installed with the Android SDK manager; the file appears under tools/lib/dx.jar I do NOT see the file in versions above android-8 and above. However Intellij IDEA gives an error when I try to build a project with android-8 and above, saying that dx.jar doesn't exist. What gives?

我在使用 Android SDK 管理器安装的某些 Android SDK 版本中看到的 dx.jar 文件的用途是什么?该文件出现在 tools/lib/dx.jar 下,我在 android-8 及以上版本中看不到该文件。但是,当我尝试使用 android-8 及更高版本构建项目时,Intellij IDEA 出现错误,说 dx.jar 不存在。是什么赋予了?

Thanks, Tom

谢谢,汤姆

采纳答案by yorkw

Additional to CommonsWare's comment.

CommonsWare 评论的补充。

The dx.jar was original located under android-sdk/platforms/android-X/tools/lib/before (especially in android-3 and android-4), and moved to android-sdk/platform-tools/lib/later. Unfortunately this has never documented in any official source, probably because it is part of internal tools which Google doesn't want to consumer developer to be bothered. check out this blogto see the problem.

dx.jar 最初位于android-sdk/platforms/android-X/tools/lib/之前(尤其是在 android-3 和 android-4 中),并移动到了android-sdk/platform-tools/lib/之后。不幸的是,这从未在任何官方来源中记录,可能是因为它是内部工具的一部分,谷歌不希望消费者开发人员受到打扰。查看此博客以查看问题。

As long as you follow Android installation guideand add android-sdk/tools/ and android-sdk/platform-tools/ to your PATH environment variable, you should be fine to access dx.jar, unless you use a really old Android SDK version (I doubt that).

只要您按照Android 安装指南并将 android-sdk/tools/ 和 android-sdk/platform-tools/ 添加到您的 PATH 环境变量中,您就可以访问 dx.jar,除非您使用的是非常旧的 Android SDK 版本(我不信)。

Last, as a quick reference, this is command how SDK typically use dx.jar to dex you java bytecode with external jar libraries:

最后,作为快速参考,这是 SDK 通常如何使用 dx.jar 使用外部 jar 库将 Java 字节码 dex 的命令:

[INFO] C:\Program Files\Java\jdk1.6.0_21\jre\bin\java [-Xmx1024M, -jar, C:\Program Files\Android\android-sdk\platform-tools\lib\dx.jar, --dex, --output=C:\workspace\myproject\target\classes.dex, C:\workspace\myproject\target\classes, C:\workspace\myprojec\libs\common-lib.jar, ... ...]

[信息] C:\Program Files\Java\jdk1.6.0_21\jre\bin\java [-Xmx1024M, -jar, C:\Program Files\Android\android-sdk\platform-tools\lib\dx.jar, --dex, --output=C:\workspace\myproject\target\classes.dex, C:\workspace\myproject\target\classes, C:\workspace\myprojec\libs\common-lib.jar, ... ...]

回答by Kiwi

Currently, dx.jarhas been moved to

目前,dx.jar已移至

adt-bundle-*\sdk\build-tools.0.0\lib

You can find the source code of dx here.

你可以在这里找到 dx 的源代码。

回答by Tom

For some reason I do see several versions (different size files) of dx and dx.jar in the various android sdk version subdirectories. I had been managing the SDKs through Eclipse, which a few months ago changed in this regard (now with a separate SDK Manager window) - so perhaps things got screwed up somehow in that transition process...

出于某种原因,我确实在各种 android sdk 版本子目录中看到了 dx 和 dx.jar 的多个版本(不同大小的文件)。我一直在通过 Eclipse 管理 SDK,几个月前在这方面发生了变化(现在有一个单独的 SDK 管理器窗口)——所以也许在那个过渡过程中事情以某种方式搞砸了......