Android ButterKnife和注释处理器

Android ButterKnife和注释处理器,android,android-gradle-plugin,butterknife,Android,Android Gradle Plugin,Butterknife,基于lib,我升级到新版本8.5.1。我曾经 compile 'com.jakewharton:butterknife:8.5.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 但它在我的Android Studio 2.3中警告我。ButterKnife不工作(无法绑定视图) 警告:使用不兼容的插件进行批注处理: android-apt。这可能会导致意外行为 我将annotationProcessor更

基于lib,我升级到新版本8.5.1。我曾经

compile 'com.jakewharton:butterknife:8.5.1'
  annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
但它在我的Android Studio 2.3中警告我。ButterKnife不工作(无法绑定视图)

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

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

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

设置>生成、执行、部署>编译器>注释 处理器

谁能解释这个问题?谢谢

好心

//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
}

Gradle版本2.2中包含注释处理器,因此没有理由提供额外的处理器


检查我的最新答案。

简单易懂。只需将这些行添加到您的build.gradle


不。我在2.3中使用了相同的东西,没问题。我不知道,您是否使用
apply插件:“com.neenbedankt.android apt”
@基兰本尼约瑟夫诺普……我不使用它。我和你有同样的问题。检查我的答案。我会检查的,谢谢。但是当我们使用
classpath'com.jakewharton:butterknife-gradle插件:8.5.1'
作为父级gradle时。我们只需要
apply插件:“com.jakewharton.butterknife”
就可以正确使用模块。无需
编译'com.jakewharton:butterknife:8.5.1'注释处理器'com.jakewharton:butterknife编译器:8.5.1'
?就我而言,
compile'com.jakewharton:butterknife:8.5.1'
annotationProcessor'com.jakewharton:butterknife编译器:8.5.1'
是必需的..我希望有人在投票时告诉我哪里错了。
//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
}
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
To use Butter Knife in directly project:
dependencies {
  implementation 'com.jakewharton:butterknife:9.0.0-rc2'
  annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
}

To use Butter Knife in a library, add the plugin to your buildscript:

buildscript {
  repositories {
    mavenCentral()
   }
  dependencies {
    classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
  }
}

apply it in your module:

apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'