Can lambda expressions be used? And in general – can Java 8 be added there?
Only officially, not left-handed.
Answer 1, authority 100%
Available in Android Studio 3.0. Lambdas are available in it for any minSdkVersion, it is enough to add to each module, either containing Java 8 code, or containing dependencies with Java 8 bytecode.
android {
...
// Configure only for each module that uses Java 8
// language features (either in its source code or
// through dependencies).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
All details here
https://developer.android.com/studio/write/java8-support.html
Answer 2, authority 80%
There is a description in the documentation :
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
this needs to be added to build.gradle
Answer 3, authority 20%
To the above methods of supporting labmda expressions I will add one more:
dependencies {
classpath 'me.tatarka: gradle-retrolambda: 3.2.5' // lambda support
}
Answer 4, authority 20%
Yes, you can. You don’t have to do anything, it supports Java 8 and lambdas by default. But it will only work on Android 7 and higher.