問題
在網上下載一個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 一下