Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which versions of Android SDK support coding in which versions of Java?

I was writing an Android app for Android SDK 2.3.3 but then I was asked to test it on a device running Android 2.2.1. So I set my target to 8 instead of 10. But then java.util.concurrent.TimeUnit only had the Java 1.5 feature set instead of the Java 1.6/1.7 feature set of java.util.concurrent.TimeUnit. So I put the openjdk 6 implementation of TimeUnit into my package for my Android app and everything works fine.

Does anyone know where I can get some documentation that gives me a chart that tells me, for example, that when using the official SDK, Android 2.2 has to be coded using Java 1.5 keywords/syntax/APIs, Android 2.3.3 can be coded using Java 1.6 keywords/syntax/APIs, etc...?

like image 775
Robert Louis Murphy Avatar asked May 17 '12 14:05

Robert Louis Murphy


People also ask

What version of Java is supported by Android?

Current tools can support all Java 7 and a few Java 8 features on all versions of Android. Additional Java 8 features are only available on API Level 24+, usually because they rely upon certain classes that were only added to the Android SDK at that point.

Does Android Studio support Java 15?

Can we use the latest version - Java 15? We can use JDK 15 for running Gradle builds as it supports the latest Java version since Gradle 6.7. Unfortunately, we cannot use Java 15 language features in our code.

Does Android SDK include Java?

They perform a lot better than Windows when it comes to Android development. Since Android's source code is in Kotlin (or Java), you'll need to install the Java Development Kit (JDK) as well. You can download it here. This installation pack contains both Android Studio and the SDK (software development kit).

Can I use Java 17 for Android Studio?

As per the docs, JDK 17 isn't supported yet in Android Studio. Actually, JDK 11 was supported starting from version 4.2 which was released in April 2021.


1 Answers

You are trying to look at Android as a subset of Java which it is not. They are completely separated. Even though Android comes from Java, it as departed from it quite a bit and there is no correlation 'version-wise' anymore between the two.

What you can look at is the Android documentation. For every instruction/command/method/properties, at the top right you'll find the api level at which you are able to access said property.

Clicking on the api level will take you to a page which contains a table that translates api level to Android versions.

The easy way to find out if you are allowed to use a property is using eclipse and doing what you just did : Change the target api level. Then any call to methods or properties that are not available to you will produce fatal errors.

like image 115
Yahel Avatar answered Sep 19 '22 08:09

Yahel