ButterKnife点击事件无效或控件绑定为空

来源:互联网 发布:火龙女电影知乎 编辑:程序博客网 时间:2024/05/16 17:48

出现ButterKnife无效的原因就是在ButterKnife从7.x到8.x后,运行时和编译器被分开来

所以在引入时我们还需要引入编译包

引入步骤:

1、在项目的build.gradle文件中引入

buildscript {    repositories {        jcenter()    }    dependencies {        classpath 'com.android.tools.build:gradle:2.2.3'        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    }}
2、在mudule的build.gradle文件中引入

apply plugin: 'com.android.application'apply plugin: 'com.neenbedankt.android-apt'
3、在mudule的build.gradle文件中引入
dependencies {      compile 'com.jakewharton:butterknife:8.5.1'    apt 'com.jakewharton:butterknife-compiler:8.5.1'}

OK






0 0