我在 Android Studio 中使用什么版本的 JDK 有关系吗? [英] Does it matter what version of JDK I use in Android Studio?

查看:41
本文介绍了我在 Android Studio 中使用什么版本的 JDK 有关系吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以在 Android Studio 的项目结构中选择 SDK 位置.

I know I can choose the SDK location in Android Studio's Project Structure.

我有两个问题:

  1. 既然已经在使用Android SDK,为什么还需要JDK?毕竟,我们不是为 JVM 开发的.

  1. Why do we need JDK when we are already using Android SDK? After all, we are not developing for JVM.

使用 JDK 1.6、1.7 和 1.8 有什么区别吗?

Is there any difference between using JDK 1.6, 1.7 and 1.8?

推荐答案

既然已经在使用Android SDK,为什么还需要JDK?毕竟,我们不是为 JVM 开发的.

Why do we need JDK when we are already using Android SDK? After all, we are not developing for JVM.

Android 构建过程依赖于 JDK 中的许多工具.查看构建系统概述文档.我们需要从 JDK 中获得的第一大块是 javac - 所有用 Java 编写的源代码都需要先编译,然后才能转换为 DEX 格式.

The Android build process depends on a number of tools from the JDK. Check out the build system overview documentation. The first big piece we need from JDK is javac- all your source code written in Java needs to be compiled before it can be converted to the DEX foramt.

一旦你的代码被编译、dexed 并打包成 APK,我们需要 jarsigner 来签署 APK.

Once your code has been compiled, dexed, and packaged into an APK, we need jarsigner to sign the APK.

使用 JDK 1.6、1.7 和 1.8 有什么区别吗?这取决于您使用每个功能的功能.不使用 Java 7 功能的旧项目可以毫无问题地使用 Java 6.我个人推荐 Java 7 用于大多数现代项目.如果你可以使用它,为什么不呢?

Is there any difference between using JDK 1.6, 1.7 and 1.8? That depends on what features you are using from each. Older projects that don't use Java 7 features can use Java 6 without issue. I personally recommend Java 7 for most modern projects. If you can use it, why not?

为将 Java 8 功能引入 Android 做了一些努力,最著名的是 gradle-retrolambda.其中一些需要 JDK 8 才能正确编译.

There are some efforts out there to bring Java 8 features to Android, most notably gradle-retrolambda. Some of these require JDK 8 to compile properly.

这篇关于我在 Android Studio 中使用什么版本的 JDK 有关系吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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