ButterKnife 8.4.0 @BindView 失败,nullpointerexception
生活随笔
收集整理的這篇文章主要介紹了
ButterKnife 8.4.0 @BindView 失败,nullpointerexception
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
ButterKnife 8.4.0
@BindView 失敗,空指針異常,跟蹤進去,發現是XXXFragment的 XXXFragment$$ViewBinder 的類沒有生成。
經過google。發現了解決方案。記錄一下。
ButterKnife?8.4.0 not working
Per?the readme, you need to include the?butterknife-compiler?in order 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.4.0' apt 'com.jakewharton:butterknife-compiler:8.0' }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)?and looking in Logcat
簡單的說呢。就是之前只加了
compile 'com.jakewharton:butterknife:8.4.0'
沒有加上
apt 'com.jakewharton:butterknife-compiler:8.4.0' 所以要在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.4.0'apt 'com.jakewharton:butterknife-compiler:8.4.0'
總結
以上是生活随笔為你收集整理的ButterKnife 8.4.0 @BindView 失败,nullpointerexception的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Mac系统如何配置adb路径
- 下一篇: 一种Android闪屏页实现方法(偏门别