What is the state of compatibility between JDK 1.8 and Android?

The latest SiO2 source code refers to Java’s Consumer interface… which means it technically requires JDK 1.8. I’ve been compiling it with target 1.7 which JDK 1.8 allows me to do. Newer JDKs are smarter and will do more checks which makes it uncomfortable to use 1.8-specific classes with a 1.7 target (class version).

So I’m wondering, is Android fine with 1.8 class files (version 52)?

Of if I upgrade SiO2 to -target 1.8 will I be messing with Android devs that might be using my libraries?

1 Like

It should be fine. A quick google search revealed that the Consumer interface is added to Android in API level 24 (Android 7).

1 Like

It’s fine, i am using jdk-1.8 on android and everything runs fine.

With -target 1.8 or 1.7?

Just trying to be sure.

Yes, with targetCompatibility JavaVersion.VERSION_1_8, there is an example on :

Also, notice the desugaring support which enables a backward compatibility for some newly introduced apis (as Consumer) for older android versions, honestly i haven’t tried desugaring before.

A complete list of supported java8 apis on android :

For those following along at home, I’ve committed the build changes to the SiO2 library that take it up to target version 1.8.

Coincidentally, this will be part of an eventual SiO2 1.8.0 release… which I couldn’t have planned if I tried.