Use Lambda and Butterknife expressions
I tried to use lambda expressions in my code and I got this error: lambda expressions are not supported at this language level
I just search for it on SO and found a solution by adding this to my gradle file:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
...
jackOptions {
enabled true
}
}
Then I got a new error: Error: Could not get unknown property 'classpath' for task ': app: transformJackWithJackForDebug' of type com.android.build.gradle.internal.pipeline.TransformTask.
Searched SO again and found that this is because I cannot use jack and apt at the same time ... so I am removing apt removing these lines:
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
...
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
...
}
And got a new error because ButterKnife needs apt ...
So how do you use Lambda and Butterknife in the same project?
source to share
You must use the annotation processor for the Butter-knife library inbuild.gradle
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
Full Gradle Looks Like:
buildscript {
repositories {
....
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
.....
}}
apply plugin: 'me.tatarka.retrolambda'
......
android{
.....
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
}
dependencies {
..........
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
}
}
NOTE. Don't use jackOption = Enabled
source to share