android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor'

本文详细介绍了如何解决Android开发中遇到的Annotation Processors必须显式声明的问题,包括修改build.gradle文件,调整annotationProcessor配置,以及设置javaCompileOptions等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

根据网络的解决方法是:

一、把project目录下的build.gradle中的classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.8'删除掉;

二、把具体Module目录下的build.gradle中的apply plugin: ‘com.neenbedankt.android-apt’删除;

三、同时把dependencies中原来使用apt的改为annotationProcessor,然后Sync Now即可。


我在外部的build.gradle中的classpath'com.neenbedankt.gradle.plugins:android-apt:1.8'注释了,但是在内部build.gradle找不到apply plugin: ‘com.neenbedankt.android-apt’,同样dependencies中也没有apt

解决方法是:

在内部的build.gradle的顶部删除 applyplugin:'android-apt'会出来一个更新 点击更新,外部的classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'都不用修改 ,就完成了。

弄完了之后还是 报错

Error:Execution failed for task ':app:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now.  The following dependencies on the compile classpath are found to contain annotation processor.  Please add them to the annotationProcessor configuration.
    - butterknife-compiler-8.6.0.jar (com.jakewharton:butterknife-compiler:8.6.0)
  Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.  Note that this option is deprecated and will be removed in the future.
  See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

解决办法:

android{

defaultConfig{

....

...

javaCompileOptions {

annotationProcessorOptions {

includeCompileClasspath true

}

}

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值