[Solved] How use java 8 in Android api 21?


Comments by @leonardkraemer and @gabe-sechan cover most of the topic.

For most of the features you pretty much just have to use desugaring and Android Studio 3+. After you set java version, like shown below, Android Studio will start suggesting Java 8 things in your code.

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

Streams are not a language feature, but a library, so there’s a good port of it: https://github.com/aNNiMON/Lightweight-Stream-API. This library covers java.util.stream and java.util.function.

solved How use java 8 in Android api 21?