bufferknife框架的配置方式

来源:互联网 发布:高级人体建模软件 编辑:程序博客网 时间:2024/05/18 00:55

第一种方式:https://jingyan.baidu.com/article/48b37f8d37ca921a64648833.html  (公司网不好没搜索出来,所                        以尝试第二种方式)


第二种方式

 

2.由于ButterKnife从7.x到8.x后,运行时和编译器被分开来,你还需要配置 apt ‘com.jakewharton:butterknife-compiler:8.1.0’,在project的build.gradle里的dependencies 作如下配置:

 dependencies {    classpath 'com.android.tools.build:gradle:2.2.0'    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}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

3.在app的build.gradle里的最上面作如下配置:

apply plugin: 'com.android.application'apply plugin: 'com.neenbedankt.android-apt'
  • 1
  • 2
  • 3

4.在app的build.gradle里的dependencies 作如下配置:

compile 'com.jakewharton:butterknife:8.0.1'apt 'com.jakewharton:butterknife-compiler:8.0.1'
5:执行 Sync Now


6:然后选中布局,右键选择Generate    然后选择  Generate Butterknife injections  选项,之后选择需要初始化的控件就可以了,如果没有这个选项,检查一下是否都配置正确,如果都正确,那么请重启studio 


原创粉丝点击