使用Butterknife 8.4.0的时候,程序报了个空指针的异常,搜阅了官方文档和作者的github,发现主要是gradle上少了点代码;
1.在项目文件的“build.gradle”文件下配置这句话:classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
Configure your project-level build.gradle
to include the 'android-apt' plugin:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
Then, apply the 'android-apt' plugin in your module-level build.gradle
and add the Butter Knife dependencies:
apply plugin: 'android-apt'
android {
...
}
dependencies {
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
}
官网地址:http://jakewharton.github.io/butterknife/
ButterKnife作者Github:https://github.com/JakeWharton/butterknife