How to set sourceCompatability to javaVersion.VERSION_1_8… here is a solution to the problem.
How to set sourceCompatability to javaVersion.VERSION_1_8
I installed jdk1.8.0_112 and wrote the following code in build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
I get this error
Error:Jack is required to support java 8 language features. Either enable Jack or remove sourceCompatibility JavaVersion.VERSION_1_8.
Can anyone help me?
Solution
From https://developer.android.com/guide/platform/j8-jack.html, you also need the following:
defaultConfig {
...
jackOptions {
enabled true
}
}
Update
Note that the Jack toolchain is now deprecated https://android-developers.googleblog.com/2017/03/future-of-java-8-language-feature.html