ButterKnife 8.0.1版本在AndroidStudio中的配置

今天在AndroidStudio中使用ButterKnife时出现了问题,总是出现空指针,最终从网上找到解决办法。

1.Project的build.gradle文件中增加classpath

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

2.在Module的build.gradle文件中增加plugin

apply plugin: 'com.neenbedankt.android-apt'

3.在Dependencies中增加下面两句

compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
    原文作者:码农仔
    原文地址: https://www.jianshu.com/p/bf9018c1a7f6
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞