使用 butterknife 这个库时,添加依赖:
implementation 'com.jakewharton:butterknife:5.1.1'
在gradle 2.1.2版本没问题,但是在gradle 3.0+ 的话就会报错:
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
添加了:
annotationProcessor "com.jakewharton:butterknife-compiler-5.1.1"
有提示找不到:
Could not find com.jakewharton:butterknife-compiler-5.1.1:.
这里提供一个更简便的方法:
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
}
defaultConfig 这个闭包中添加:
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
问题解决。。。。