Android使用Butter Knife8.2.1空指针
来源:互联网 发布:cookie登录 php 编辑:程序博客网 时间:2024/06/05 03:02
之前使用的是utter Knife7.0.1的版本,一切正常,今天心血来潮,将其更新为最新版本的8.2.1版本了,本以为换一下版本号就OK了,在运行的时候发现绑定的View都为空,查看了官网相关文档顺利解决问题,再更改版本号的基础上还需要增加一些配置,记录步骤如下:
第一步:打开Project的build.gradle文件,修改buildscript,添加
classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.8’
修改后内容如下:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}
第二步:打开Module的build.gradle文件,添加
apply plugin: ‘android-apt’
另外需要在dependencies中添加
apt ‘com.jakewharton:butterknife-compiler:8.2.1’
完整配置如下:
apply plugin: 'com.android.application'apply plugin: 'android-apt'android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "com.jianggujin.lifeassistant" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }}dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.readystatesoftware.systembartint:systembartint:1.0.3' compile 'com.android.support:design:23.4.0' compile 'com.squareup.okhttp3:okhttp:3.4.1' compile 'com.jakewharton:butterknife:8.2.1' apt 'com.jakewharton:butterknife-compiler:8.2.1'}
最后我们同步一下项目,再次编译运行,绑定的View可以被正常注入了。
2 0
- Android使用Butter Knife8.2.1空指针
- 使用Butter Knife报空指针
- Android Studio 3.0集成Butter Knife8.8.1错误
- 解决Butter Knife 空指针问题
- 解决Butter Knife 空指针问题
- Butter Knife@BindView控件空指针问题
- Android Butter Knife使用
- Android-使用Fragment出现空指针错误
- Buffer Knife8.4.0的配置以及使用
- android studio上使用butter Knife
- Android中Butter Knife库使用
- android studio上使用butter Knife
- android空指针异常
- android 空指针异常
- 【Android 基础】使用getActionBar()报空指针异常的解决方法
- Android Studio使用ButterKnife注解 出现空指针异常解决办法
- Android Studio使用Butterknife时出现空指针问题解决
- Android Studio使用Butterknife时出现空指针问题解决
- MySQL笔记-MySQL支持的字段类型(dataType)
- linux下安装安装pcre-8.32 configure: error: You need a C++ compiler for C++ support
- 前K个最频繁的元素
- C语言"文件处理"
- 第六届CCF计算机职业资格认证(试题B)
- Android使用Butter Knife8.2.1空指针
- Linux网络编程【2】
- 快速幂取模(转载)
- 7种形式的Android Dialog使用举例
- 应用内切换主题有哪些方案可以实现
- javaweb--Tomcat>>更改Tomcat的默认配置
- js进阶学习之--闭包的理解
- 论高中“集”与C语言“数组”的关系
- XCode 快捷键