ButterKnife和AnnotationProcessor

RoS*_*han 3 android android-gradle-plugin butterknife

基于ButterKnife lib,我升级到新版本8.5.1.我用了

compile 'com.jakewharton:butterknife:8.5.1'
  annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
Run Code Online (Sandbox Code Playgroud)

但它在我的Android Studio 2.3中警告我.并且ButterKnife不起作用(不能绑定视图).

警告:使用不兼容的插件进行注释处理:android-apt.这可能会导致意外行为.

我将annotationProcessor更改 为apt(apply plugin: 'com.neenbedankt.android-apt'我的gradle中有插件)并且它在没有警告的情况下作为旧版本工作(我在旧版本8.4.0中使用了apt)

compile 'com.jakewharton:butterknife:8.5.1'
apt 'com.jakewharton:butterknife-compiler:8.5.1'
Run Code Online (Sandbox Code Playgroud)

我认为Android Studio 2.3与Annottaion处理不兼容.我搜索并发现在Android Studio 2.2中启用了注释处理器,但在Android Studio 2.3中找不到

设置>构建,执行,部署>编译器>注释处理器

有谁能解释这个问题?谢谢!

Zer*_*One 6

和蔼

//apply plugin: 'com.neenbedankt.android-apt'  <--remove this
apply plugin: 'com.jakewharton.butterknife'  <-- add this


dependencies {
    //classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'  <-- remove this
    classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1' <-- add this
}
Run Code Online (Sandbox Code Playgroud)

然后在应用程序依赖项中

//牛油刀

compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
Run Code Online (Sandbox Code Playgroud)