简体   繁体   English

为什么Android SDK需要JDK?

[英]Why does the Android SDK need a JDK?

I am trying to understand why the Android SDK needs the JDK. 我试图理解为什么Android SDK需要JDK。

  • The Android SDK is not supposed to have all the JDK Java classes it needs (with potential implementation differences) ? Android SDK不应该拥有它需要的所有JDK Java类(潜在的实现差异)?
  • Does it need it for all the tools included in the JDK ? 是否需要JDK中包含的所有工具?
  • Do we use the JDK when we build .dex & .apk files ? 我们在构建.dex和.apk文件时是否使用JDK?
  • What does it mean to say that Android Java classes must be written with Java 5 or 6 compiler compliance ? 说Java Java类必须用Java 5或6编译器兼容性编写是什么意思?

Thanks 谢谢

ANdoBuild

The general process for a typical build is outlined below: 典型构建的一般过程概述如下:

  • The Android Asset Packaging Tool (aapt) takes your application resource files, such as the AndroidManifest.xml file and the XML files for your Activities, and compiles them. Android资产包装工具(aapt)获取您的应用程序资源文件,例如AndroidManifest.xml文件和您的活动的XML文件,并编译它们。 An R.java is also produced so you can reference your resources from your Java code. 还生成了R.java,因此您可以从Java代码中引用您的资源。
  • The aidl tool converts any .aidl interfaces that you have into Java interfaces. aidl工具将您拥有的任何.aidl接口转换为Java接口。
  • All of your Java code, including the R.java and .aidl files, are compiled by the Java compiler and .class files are output. 所有Java代码(包括R.java和.aidl文件)都由Java编译器编译,并输出.class文件。
  • The dex tool converts the .class files to Dalvik byte code. dex工具将.class文件转换为Dalvik字节代码。 Any 3rd party libraries and .class files that you have included in your project are also converted into .dex files so that they can be packaged into the final .apk file. 您包含在项目中的任何第三方库和.class文件也会转换为.dex文件,以便将它们打包到最终的.apk文件中。
  • All non-compiled resources (such as images), compiled resources, and the .dex files are sent to the apkbuilder tool to be packaged into an .apk file. 所有未编译的资源(例如图像),编译的资源和.dex文件都将发送到apkbuilder工具以打包到.apk文件中。
  • Once the .apk is built, it must be signed with either a debug or release key before it can be installed to a device. 构建.apk后,必须先使用调试密钥或释放密钥对其进行签名,然后才能将其安装到设备上。
  • Finally, if the application is being signed in release mode, you must align the .apk with the zipalign tool. 最后,如果应用程序在发布模式下签名,则必须将.apk与zipalign工具对齐。 Aligning the final .apk decreases memory usage when the application is running on a device. 当应用程序在设备上运行时,对齐最终的.apk会减少内存使用量。

More referance here.. 更多的参考在这里..

Android SDK使用JDK将.java文件编译为.class字节码。

When you build the project all .java files get converted to .class. 构建项目时,所有.java文件都将转换为.class。 For which you need JDK. 你需要JDK。

Now the dx tool of adk converts all .class files to classes.dex file .And this classes.dex file is executed on dalvik virtual machine. 现在adk的dx工具将所有.class文件转换为classes.dex文件。此classes.dex文件在dalvik虚拟机上执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM