Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does java 11 support android?

I am new to android development. And I have installed eclipse, java 11 and android sdk tools in my computer. But when I try to build a project it says that to upgrade tools. But I have installed the latest sdk.

When I'm reading in internet I found that android doesn't fully support java SE and it mostly support for java SE 6 and 7. - but this was an old post .

I found that android do not support java 11 completely.

My question is, what is the JDK version that fully support android and do I have to install 2 versions of JDK s in my computer?

like image 665
Seniru Pasan Avatar asked Nov 24 '18 07:11

Seniru Pasan


People also ask

Can I use Java 11 in Android?

Compilation with JDK11 is no longer supported in Android Studio 3.5 Beta 3.

Which version of Java is used for Android?

Class libraryJava 8 source code that works in latest version of Android, can be made to work in older versions of Android.

Is Java 11 supported?

Oracle intends to support the Java LTS releases as follows: Java 7 through 2022. Java 8 through at least 2030. Java 11 through 2026.


1 Answers

With Android Studio Arctic Fox | 2020.3.1 finally you can use Java 11 in your project, here more info: https://developer.android.com/studio/releases/gradle-plugin?utm_source=android-studio-2020-3-1&utm_medium=studio-assistant-stable#java-11

You can now compile up to Java 11 source code in your app’s project, enabling you to use newer language features like private interface methods, the diamond operator for anonymous classes, and local variable syntax for lambda parameters.

To enable this feature, set compileOptions to the desired Java version and set compileSdkVersion to 30 or above

// build.gradle  android {     compileSdkVersion 30      compileOptions {       sourceCompatibility JavaVersion.VERSION_11       targetCompatibility JavaVersion.VERSION_11     }      // For Kotlin projects     kotlinOptions {       jvmTarget = "11"     } } 
like image 145
mycky Avatar answered Sep 29 '22 19:09

mycky