studio3.0Butterknife使用及报错解决

来源:互联网 发布:全世界讨厌中国人知乎 编辑:程序博客网 时间:2024/05/17 01:02

第一步添加依赖

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    }}
原创粉丝点击