Android Studio 警告:使用不兼容的插件进行注释处理
Android Studio Warning: Using incompatible plugins for the annotation processing
更新 Android Studio 到 2.3 版本后我有警告:
Warning:Using incompatible plugins for the annotation processing:
android-apt. This may result in an unexpected behavior.
有什么解决办法吗?我的应用程序停止工作...
您的应用级别 gradle 依赖项应包括(根据 butterknife 网站说明):
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
您可以删除以下行:
apply plugin: 'com.neenbedankt.android-apt'
注释处理在 Android Gradle 插件(2.2 及更高版本)中可用,因此如果使用此版本的 gradle 或更高版本,现在无需再使用上述插件.
如果您想知道如何关闭和打开注释处理以及设置在:
设置 > 构建、执行、部署 > 编译器 > 注释处理器
在我的项目中,我使用了 Butter Knife 和 Immutables。添加不可变后,我收到以下警告
Warning:Using incompatible plugins for the annotation processing:
android-apt. This may result in an unexpected behavior.
ButterKnife 停止工作。
我的配置如下:
build.gradle(项目:MyApplication)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
build.gradle(模块:应用)
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
...
dependencies {
...
// Butter Knife
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
// Immutables
apt 'org.immutables:value:2.4.4'
provided 'org.immutables:value:2.4.4'
provided 'org.immutables:builder:2.4.4'
provided 'org.immutables:gson:2.4.4'
}
改变后
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
到
apt 'com.jakewharton:butterknife-compiler:8.5.1'
警告消失,一切正常。
更新
正如 Mark 所说,Gradle 2.2 版中包含了注释处理器,因此没有理由提供额外的注释处理器。
所以:
1) 从 build.gradle(项目:MyApplication)
中删除 apt 的 class 路径
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
2) 从build.gradle (Module: app)
移除插件
apply plugin: 'android-apt'
3) 将依赖项从 apt 更改为新的 annotationProcessor
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
annotationProcessor 'org.immutables:value:2.4.4'
要添加到@Milan 的答案中,如果您在应用级别 gradle 文件中使用了 hotchemi permissiondispatcher 库,那么您应该按如下方式替换它:
替换
apt 'com.github.hotchemi:permissionsdispatcher-processor:2.4.0'
和
annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.4.0'
在项目 Gradle buildscript --> dependencies
块中,删除第二个 classpath
行:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
然后在 app Gradle dependencies
块中,更改这些行,使用 api
和 annotationProcessor
:
api 'com.google.dagger:dagger:2.19'
annotationProcessor 'com.google.dagger:dagger-compiler:2.19'
另外,删除这个:
//apply plugin: 'com.neenbedankt.android-apt'
更新 Android Studio 到 2.3 版本后我有警告:
Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.
有什么解决办法吗?我的应用程序停止工作...
您的应用级别 gradle 依赖项应包括(根据 butterknife 网站说明):
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
您可以删除以下行:
apply plugin: 'com.neenbedankt.android-apt'
注释处理在 Android Gradle 插件(2.2 及更高版本)中可用,因此如果使用此版本的 gradle 或更高版本,现在无需再使用上述插件.
如果您想知道如何关闭和打开注释处理以及设置在:
设置 > 构建、执行、部署 > 编译器 > 注释处理器
在我的项目中,我使用了 Butter Knife 和 Immutables。添加不可变后,我收到以下警告
Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.
ButterKnife 停止工作。
我的配置如下:
build.gradle(项目:MyApplication)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
build.gradle(模块:应用)
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
...
dependencies {
...
// Butter Knife
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
// Immutables
apt 'org.immutables:value:2.4.4'
provided 'org.immutables:value:2.4.4'
provided 'org.immutables:builder:2.4.4'
provided 'org.immutables:gson:2.4.4'
}
改变后
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
到
apt 'com.jakewharton:butterknife-compiler:8.5.1'
警告消失,一切正常。
更新
正如 Mark 所说,Gradle 2.2 版中包含了注释处理器,因此没有理由提供额外的注释处理器。
所以:
1) 从 build.gradle(项目:MyApplication)
中删除 apt 的 class 路径classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
2) 从build.gradle (Module: app)
移除插件apply plugin: 'android-apt'
3) 将依赖项从 apt 更改为新的 annotationProcessor
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
annotationProcessor 'org.immutables:value:2.4.4'
要添加到@Milan 的答案中,如果您在应用级别 gradle 文件中使用了 hotchemi permissiondispatcher 库,那么您应该按如下方式替换它:
替换
apt 'com.github.hotchemi:permissionsdispatcher-processor:2.4.0'
和
annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.4.0'
在项目 Gradle buildscript --> dependencies
块中,删除第二个 classpath
行:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
然后在 app Gradle dependencies
块中,更改这些行,使用 api
和 annotationProcessor
:
api 'com.google.dagger:dagger:2.19'
annotationProcessor 'com.google.dagger:dagger-compiler:2.19'
另外,删除这个:
//apply plugin: 'com.neenbedankt.android-apt'