ButterKnife 8.0.1 @BindView 失败,nullpointerexception
2017-05-09 21:26
447 查看
ButterKnife 8.0.1 @BindView 失败,空指针异常,跟踪进去,发现是XXXFragment的 XXXFragment$$ViewBinder 的类没有生成。经过google。发现了解决方案。记录一下。
ButterKnife8.0.1 not working
Per the readme, you need to include thebutterknife-compilerinorder for the generated code to be produced automatically:
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' } } apply plugin: 'com.neenbedankt.android-apt' dependencies { compile 'com.jakewharton:butterknife:8.0.1' apt 'com.jakewharton:butterknife-compiler:8.0.1' }Without this there is no generated code to be loaded and thus none of the fields get set.You can verify ButterKnife is working by calling
ButterKnife.setDebug(true)andlooking in Logcat简单的说呢。就是之前只加了
compile 'com.jakewharton:butterknife:8.0.1'没有加上
apt 'com.jakewharton:butterknife-compiler:8.0.1'所以要在Module的build.gradle 加上
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'在app 的build.gradle顶部加上
apply plugin: 'com.neenbedankt.android-apt'dependencies加上
compile 'com.jakewharton:butterknife:8.0.1'apt 'com.jakewharton:butterknife-compiler:8.0.1'
相关文章推荐
- ButterKnife 8.0.1 @BindView 失败,nullpointerexception
- ButterKnife 8.0.1 @BindView 失败,nullpointerexception
- ButterKnife 8.4.0 @BindView 失败,nullpointerexception
- ButterKnife BindView 失败,报错NullPointerException
- 关于butterknife8.0.1提示NullPointerException空指针的问题
- ButterKinfe.bind(this) @BindView时出现NullPointerException
- ButterKnife.bind(this)发生NullPointerException
- Eclipse中使用butterknife出现nullPointerException
- Android Butterknife 8.4.0 使用时报错java.lang.NullPointerException
- 解决Android Studio 3.0.1 下使用ButterKnife 8.8.1版本出现 nullpointerexception 等异常问题
- TextView.setText() throwing NullPointerException问题
- NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParam
- NullPointerException at android.widget.AbsListView.obtainView at android.widget.GridView.onMeasure
- NullPointerException at android.widget.AbsListView.obtainView at android.widget.GridView.onMeasure
- PopupWindow错误:PopupWindow$1.onScrollChanged 出现 NullPointerException和PopupViewContainer.dispatchKeyEvent 出现 NullPointerException
- NullPointerException at android.widget.AbsListView.obtainView.
- 在onAnimationEnd方法中调用 viewgroup.removeview,报 nullpointerexception异常的解决方法
- Android Listview addHeaderView setadapter的时候莫名NullPointerException 解决
- AIDL:远程调用服务里的方法失败,提示取得的IBinder对象NullPointerException
- findViewById中NullPointerException的错误