7.0.1版本
compile 'com.jakewharton:butterknife:7.0.1'
Android studio3.0以上版本需要另外配置
annotationProcessor 'com.jakewharton:butterknife:7.0.1'
如果还报如下错
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.
- butterknife-7.0.1.jar (com.jakewharton:butterknife:7.0.1)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
需要在主module 配置如下信息,注意 主module
defaultConfig {
····
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
}
目前7.x版本已无法使用(2019.8.21)
8.0.1版本
module
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
···
dependencies {
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
project
dependencies {
···
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
8.5.1版本
module
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'
···
dependencies {
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
project
dependencies {
···
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
}
}
版本越高反而越复杂,是为了自由灵活考虑,不过真的好坑!
网友评论