Android studio 版本
gradle版本配置
项目build.gradle文件配置
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
然后就可以愉快的使用butterknife了,不用findViewById了~
Library中使用butterknife
library中build.gradle文件
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
工程build.gradle文件配置
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "com.jakewharton:butterknife-gradle-plugin:8.4.0"
}
}
classpath "com.jakewharton:butterknife-gradle-plugin:8.4.0"
注意这一句,版本用的8.4.0,而不是8.8.1。使用8.8.1编译无法通过,据说是
Android Studio3.0与butterknife的冲突。详情参见
https://blog.csdn.net/p576518762/article/details/78356137
然后就可以在Library中使用butterknife了
@BindView(R2.id.lele)
TextView lele;
不过R要改为R2,其它用法和APP中差不多
版权声明:本文为a136028440原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。