1.由于ButterKnife从7.x到8.x后,运行时和编译器被分开来,你还需要配置 apt ‘com.jakewharton:butterknife-compiler:8.1.0’,在project的build.gradle里的dependencies 作如下配置:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
2.在app的build.gradle里的最上面作如下配置:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
3.在app的build.gradle里的dependencies 作如下配置:
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'