使用第三方 Java8 兼容插件解决 lambda 与 butterknife 的兼容问题, 即使项目中没有使用到 butterknife, 也推荐使用第三方兼容插件
配置
工程的 build.gradle 中添加
- dependencies {
- classpath 'com.android.tools.build:gradle:3.3.2'
- classpath 'me.tatarka:gradle-retrolambda:3.7.0'
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
App.gradle 中添加
- apply plugin: 'com.android.application'
- apply plugin: 'me.tatarka.retrolambda'
- Android {
- ...
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- }
来源: http://www.jianshu.com/p/6c2dd6dd4446