基于 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 不起作用(无法绑定(bind) View )。
Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.
我将 annotationProcessor 更改为 apt(我的 gradle 中有插件 apply plugin: 'com.neenbedankt.android-apt'
)并且它像旧版本一样工作,没有警告(我使用 apt 旧版本 8.4.0)
compile 'com.jakewharton:butterknife:8.5.1'
apt 'com.jakewharton:butterknife-compiler:8.5.1'
我认为 Android Studio 2.3 与 Annottaion 处理不兼容。我搜索并发现在 Android Studio 2.2 中启用注释处理器,但在 Android Studio 2.3 中找不到
Settings > Build, Execution, Deployment > Compiler > Annotation Processors
谁能解释一下这个问题?谢谢!
最佳答案
亲切的
//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
}
然后在应用程序依赖项中
//butterknife
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
关于android - ButterKnife 和 AnnotationProcessor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42825172/