Has anyone played with jdk 11 in android yet?
New features in Android Studio Preview | Android Developers
Just curious as it would make porting jme applications to android much simpler as many of us now use jdk 11.
Has anyone played with jdk 11 in android yet?
New features in Android Studio Preview | Android Developers
Just curious as it would make porting jme applications to android much simpler as many of us now use jdk 11.
Yes, it’s working.
Sweet. I am getting ready to fly back to work so I won’t have a change to play with it for a couple weeks, but when I get back home I am very interested in trying out somethings.
@Pavl_G by any chance, do you know if android supports Pattern Matching? (I think it is added in java 12)
if (x instanceof Integer i) {
// can use i here, of type Integer
}
Hi @Ali_RS , i am sorry for very late reply, yes it may be presented on VERSION_12
which is not supported by AGP 7.0.2 till now, Android Arctic Fox is now on the Stable Channel, i have tested it with jme, Gradle 7.0, AGP 7.0.2, everything is fine, but i cannot use JDK11 language features, donot know why … repo :
I see. Thanks for the response @Pavl_G .
The next Java release is going to be an LTS release, I hope AGP adds support for it.
Edit:
By the way, this might be interesting
So this may be the reason why I cannot experience java11 key features on android code ? “The forkoptions”
Not sure.
I tried with Java 14 and using instanceof Pattern Matching on Android 7.1 using AGP 7.0.0 and it works fine for me.
So far var
works fine, but i cannot access other jdk11 language features, like the new String methods, etc, seems there is a one more step to enable language features not only build.
I’m using this flag if it helps.
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 14
sourceCompatibility JavaVersion.VERSION_14
targetCompatibility JavaVersion.VERSION_14
}
also enabled the preview language features
tasks.withType(JavaCompile).configureEach { task ->
task.options.compilerArgs += "--enable-preview"
}
@Ali_RS Thanks for sharing .
You’re welcome
For anyone following this thread!
Some of the recently added features to Android Dexer (D8):