ButterKinfe.bind(this) @BindView时出现NullPointerException
2017-06-12 14:35
447 查看
ButterKnife版本 8.4.0,@BindView会出现空指针异常,然后我把@BindView换成了findViewById还是报错
网上逛论坛发现,ButterKnife 8.0.1的很多使用者都会出现这种错误,究竟为什么会出现这种错误呢?
原因貌似是我们只是简单的在build,gradle添加了声明
除此之外还要在app下的build.gradle文件中添加一些配置:
添加apt声明
在依赖前面加上buildscript声明
sync就不会出现空指针异常了!
网上逛论坛发现,ButterKnife 8.0.1的很多使用者都会出现这种错误,究竟为什么会出现这种错误呢?
原因貌似是我们只是简单的在build,gradle添加了声明
compile 'com.jakewharton:butterknife:8.0.1'
除此之外还要在app下的build.gradle文件中添加一些配置:
添加apt声明
compile 'com.jakewharton:butterknife:8.4.0' apt 'com.jakewharton:butterknife-compiler:8.4.0'
在依赖前面加上buildscript声明
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' } } apply plugin: 'com.neenbedankt.android-apt' dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations'
sync就不会出现空指针异常了!
相关文章推荐
- ButterKnife BindView 失败,报错NullPointerException
- ButterKnife 8.4.0 @BindView 失败,nullpointerexception
- ButterKnife.bind(this)发生NullPointerException
- ButterKnife 8.0.1 @BindView 失败,nullpointerexception
- ButterKnife 8.0.1 @BindView 失败,nullpointerexception
- ButterKnife 8.0.1 @BindView 失败,nullpointerexception
- Eclipse中使用butterknife出现nullPointerException
- PopupWindow错误:PopupWindow$1.onScrollChanged 出现 NullPointerException和PopupViewContainer.dispatchKeyEvent 出现 NullPointerException【转载】
- android中调用findViewById时出现:java.lang.NullPointerException
- RecyclerView.addFocusables出现空指针异常NullPointerException的解决办法
- 解决Android Studio 3.0.1 下使用ButterKnife 8.8.1版本出现 nullpointerexception 等异常问题
- PopupWindow错误:PopupWindow$1.onScrollChanged 出现 NullPointerException和PopupViewContainer.dispatchKeyEvent 出现 NullPointerException
- Java Web应用部署在SAE平台上出现“java.lang.NullPointerException”错误的原因之一
- 出现 java.lang.NullPointerException 的一个案例
- Android中,在onAnimationEnd方法中调用 viewgroup.removeview,报 nullpointerexception异常的解决方法
- 出现java.lang.NullPointerException此类错误
- ListView遍历每个Item出现NullPointerException的异常
- PhoneGap2.7.0调用拍照和相册时出现onActivityResult NullPointerException问题
- Android 自定义控件布局 NullPointerException findViewById
- 使用Eclipse开发Android出现java.lang.NullPointerException错误的解决方法