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

3

39

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?

Northway answered 4/12, 2017 at 6:13 Comment(6)
@ChintanSoni Kotlin has nothing to do with Java 9Vivie
@Vivie So I'm wondered why the question is downvoted and also voted to close.Northway
@AhmadPayan I think this is mostly downvoted because Android does not support Java 9. So the question is kinda senseless.Vivie
@Vivie I see. Thanks for your hint.Northway
@AhmadPayan: the usual anonymous downvoters were at it again... but it seems to have been correctedPigmentation
Try kotlin instead.Bulrush
B
39

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.

Botha answered 4/12, 2017 at 6:23 Comment(1)
How do I get the microsecond precision in the timestamp using java 9(Instant.now()) in android? Please check this thread - https://mcmap.net/q/409859/-android-not-able-to-get-microseconds-using-java-time-instant/1584121Denman
P
8

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.

Pigmentation answered 23/2, 2018 at 13:27 Comment(5)
Though, Android is not Java. It probably never will have the exact same features as the full Java version (Java SE). It can integrate a subset of Java 9 without featuring all of 8 thoughBotha
@Zoe: True. Still, it seems like they've come a long way. See the link.Pigmentation
@VahidAmiri: did you try Java 10?Pigmentation
@Pigmentation Yes. It doesn't work. Spits out compile errors.Philipson
@VahidAmiri: thank you for the feedback. I read the post with too much wishful thinking.Pigmentation
C
6

Just tried to do it with Ubuntu 18.04 which uses Java 10 already. You run into tons of problems from invalid java certificates to extra warnings on gradle invocations etc. It's a mess and hopefully solved soon, you will find solutions to every problem via google but it's more easy to install Java 8 instead.

I have no idea about using the language itself inside Android application code, because i'm a full NDK C++ programmer and only use the toolchain which contains many java programs.

Corneliuscornell answered 28/5, 2018 at 0:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.