1. 程式人生 > >studio3.0Butterknife使用及報錯解決

studio3.0Butterknife使用及報錯解決

第一步新增依賴

implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.jakewharton:butterknife-compiler:8.8.1'

使用就是這樣
接下來是解決報錯

Annotation processors must be explicitly declared now.
The following dependenciesonthe compile classpath are found tocontain annotation processor.
Please add
themtothe annotationProcessor configuration. - butterknife-7.0.1.jar Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath =truetocontinuewith previous behavior. Notethat this option is deprecated and will be removed inthe future.

解決方法
在module的build.gradle中新增如下程式碼
需要新增在Android目錄下的defaultconfig中新增

javaCompileOptions {
    annotationProcessorOptions {
        includeCompileClasspath = true
    }
}