ButterKnife 8.5.1 >>> NullPointException

原因:

没有看清楚添加依赖的正确姿势!!!

解决:

1、如果该 module 仅作为 app 使用:
dependencies { compile 'com.jakewharton:butterknife:8.5.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' }
2、如果该 module 是作为 library 使用:

root module

buildscript { repositories { mavenCentral() } dependencies { classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1' } }

your module

apply plugin: 'com.android.library' apply plugin: 'com.jakewharton.butterknife'

使用注解时,用 R2 代替 R

class ExampleActivity extends Activity { @BindView(R2.id.user) EditText username; @BindView(R2.id.pass) EditText password; ... }
3、如果 your project 既有 app module, 又有 libary module,则相机使用

你可能感兴趣的:(ButterKnife 8.5.1 >>> NullPointException)