Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Android Studio 3 support Java 9 for Android development? If so, what features of Java 9 are supported?

I'm going to install Android Studio 3 in order to develop an Android application.

I'd like to know if it is possible to use Java 9 for Android development? If so, does it support all of the Java 9 features?

like image 753
Ahmad Payan Avatar asked Dec 04 '17 06:12

Ahmad Payan


People also ask

Does Android use Java 9?

You can't use Java 9 , Android only supports till Java 8 . You should use the JDK version that comes with Android Studio, NO need for side alone JDK. The current JDK version is based on OpenJDK 8 .

What version of Java does Android Studio support?

Android Studio supports all the same programming languages of IntelliJ (and CLion) e.g. Java, C++, and more with extensions, such as Go; and Android Studio 3.0 or later supports Kotlin and "all Java 7 language features and a subset of Java 8 language features that vary by platform version." External projects backport ...

What version of Java is used for Android development?

Note: When developing apps for Android, using Java 8 language features is optional. You can keep your project's source and target compatibility values set to Java 7, but you still need to compile using JDK 8.

Is Java in Android Studio different?

The syntax is exactly the same and you can use the same methods that are available in Java SE. Android has its own SDK (Software Development Kit) which is specific Java classes and methods for Android, i.e. dealing with click events and user interface.


2 Answers

As far as I know, the IDE itself supports Java 9. This means you can write a Java 9 desktop program, or run the IDE with JDK 9.

However, Android itself does not support Java 9 (yet). You can still download JDK 9, although I have seen some questions on problems related to Android Studio and Java 9. Personally, I have Java 9 and Android Studio runs without problems.

The Android SDK is the development kit you'll be dealing with, and with source compatibility you'll get language features similar to Java 6, 7, or 8, depending on your settings. So you can download JDK 9 and use that most likely without issues, but you can't use any of the language features in any Android apps.

As for differences between the JDK and the Android SDK, you should read this. Android currently supports a subset of Java 8 features, but not everything. It might never support everything, or leave out some parts of Java 8, even if it later supports some parts on Java 9 or higher.

like image 97
Zoe stands with Ukraine Avatar answered Sep 21 '22 05:09

Zoe stands with Ukraine


UPDATE: as of https://jakewharton.com/androids-java-8-support/, it seems like this should almost work by now (as well as for Java 9, 10, 11, and 12). Or just use Kotlin.

To help the last steps along, you can star the issue.


As of now, the Android SDK does not even support java 8 completely:

Android Studio 3.0 and later supports all Java 7 language features and a subset of Java 8 language features that vary by platform version. This page describes the Java 8 language features you can use, how to properly configure your project to use them, and any known issues you may encounter. [emphases mine]

That probably needs to be supported completely before Java 9 is approached.

like image 36
serv-inc Avatar answered Sep 20 '22 05:09

serv-inc