简体   繁体   中英

Which Java JDK should I install for the use of Android Studio

I want to install Android Studio and I saw that it is recommended to also install the Java JDK. The thing that I don't understand is that a lot of people are recommending the Java SE Development Kit 8 but the latest one is 13. Why would I use 8 instead of 13? Can anyone tell me the exact version of JDK that should be used for Android Studio?

Thanks in advance.

The official doc says:

Set the JDK version

A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects. To use the bundled JDK, do the following:

  1. Open your project in Android Studio and select File > Project Structure in the menu bar.
  2. In the SDK Location page and under JDK location, check the Use embedded JDK checkbox.
  3. Click OK.

So there is no need to install a standalone JDK if you are not planning to do Java Devs other than Android App.

Android is behind the Java development.

It uses most of Java 7 's features with some features of Java 8 (like click listeners using lambdas).

To make Android Studio "understand" Java 8, you have to add the following options to your app's build.gradle android section:

 compileOptions{
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

So, if you would like to be able to copy-paste code from your java applications to Android ones, it is better to stick to Java 8.

You can use Java 8 or java 7 for the android studio 3 or later versions. I was having some problem with java 13. After some research i found it, Android Studio 3.0 and later supports all Java 7 language features and a subset of Java 8 language features

Hope it helps:)

Unfortunately, the Chromebook installation doesn't properly install and configure if installing on one with 'aarch64' and the Mediatek processor. There are many hoops that must be jumped through, and installing and configuring a JDK beforehand, making sure that the JAVA_HOME environment variable and corresponding files and directories are all set up and working can reduce the headaches involved with the bundled version in this quirky, hard-enough to get working situation. In most cases, the above recommendations hold true, but some of us always have to tackle the 'impossible.'

You shouldn't need to install a standalone JDK in most use cases, but sometimes things are more complicated, for example KMM - the plugin doesn't help you sort out your environment problem obviously, so you need to either set up everything manually using the build-in JDK (mentioned in the accepted answer), or you can brew install oracle-jdk which works fine for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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