使用ButterKnife8以上版本,控件报空指针的问题

突然有一种把所有流行框架都用一遍的想法,想到就做。

导入了依赖之后总是提示控件空指针,最后发现8版本之后跟之前的配置有一些差别,我已出坑,希望大家也能尽快出坑。


先贴github原文

Configure your project-level build.gradle to include the 'android-apt' plugin:

buildscript {
  repositories {
    mavenCentral()
   }
  dependencies {
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
  }
}

Then, apply the 'android-apt' plugin in your module-level build.gradle and add the Butter Knife dependencies:

apply plugin: 'android-apt'

android {
  ...
}

dependencies {
  compile 'com.jakewharton:butterknife:8.2.1'
  apt 'com.jakewharton:butterknife-compiler:8.2.1'
}

再贴我自己的配置


在build.gradle(Project:xxx)中

dependencies {
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}

在build.gradle(Module:app)中

在第二行加入

apply plugin: 'com.neenbedankt.android-apt'
dependencies {
    compile 'com.jakewharton:butterknife:8.2.0'
    apt 'com.jakewharton:butterknife-compiler:8.2.0'
}


我在使用klog的时候遇到另一个坑,就是初始化的tag无效,目前还没出坑,有用过的大神,请指点一二

如果有想一起交流的小伙伴,可以加QQ群:263027541或者加我QQ:454214711 

希望能尽绵薄之力帮助到各位

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值