关于ButterKnife 8.4.0以后版本报空指针的使用注意事项:

来源:互联网 发布:淘宝怎么改追加评价 编辑:程序博客网 时间:2024/05/07 18:35

关于ButterKnife 8.4.0以后版本报空指针的解决办法:
1. 新版的ButterKnife在使用是需要在app的build.gradle中

1.dependencies{...}添加```compile 'com.jakewharton:butterknife:8.4.0'apt 'com.jakewharton:butterknife-compiler:8.4.0'```2.在`apply plugin: 'com.android.application'`代码之下添加:`apply plugin: 'com.neenbedankt.android-apt`'如下代码:```apply plugin: 'com.neenbedankt.android-apt'dependencies {    compile fileTree(include: ['*.jar'], dir: 'libs')    testCompile 'junit:junit:4.12'    compile 'com.android.support:appcompat-v7:24.1.1'    compile project(':baselibrary')    compile 'com.android.support:recyclerview-v7:24.1.1'    compile 'com.jakewharton:butterknife:8.4.0'    apt 'com.jakewharton:butterknife-compiler:8.4.0'}```
  1. 同时需要在项目的build.gradle的dependencies{…}添加

    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
0 0