问题
在网上下载一个demo,因为版本久远,里面添加了本地 Butter Knife 的jar包,在编译时报错
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 (butterknife-7.0.1.jar) 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.
看提示应该是找不到包,项目配置的问题
按照在dependencies
中增加annotationProcessor 依赖内容
的方法并没有成功
解决方法
在 app 的 build.gradle 文件中添加 includeCompileClasspath 参数:
apply plugin: 'com.android.application' android {
··· defaultConfig {
···
// 显式声明支持注解
javaCompileOptions{
annotationProcessorOptions {
includeCompileClasspath true
}
}
} } dependencies {
···
implementation files('libs/butterknife-7.0.1.jar')
···
}
重新 build 一下