Android Studio3.0 Dagger2注入报错不兼容的问题

1. 报错提示Error:android-apt plugin is incompatible with the Android Gradle plugin.  Please use 'annotationProcessor' configuration instead.

2. 报错原因经过查找发现,在Studio升级到3.0之后原来的配置方式apt与最新版本Gradle已经不兼容,推荐使用annotationProcessor,

3.解决报错

一、把project目录下的build.gradle中如果有添加配置:请classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.8'删除掉;

二、把具体Module目录下的build.gradle中如果有添加配置:请apply plugin: ‘com.neenbedankt.android-apt’删除;

三、同时dependencies中原来使用apt

implementation 'com.google.dagger:dagger:2.16'
apt 'com.google.dagger:dagger-compiler:2.16'

改为annotationProcessor

implementation 'com.google.dagger:dagger:2.16'
annotationProcessor 'com.google.dagger:dagger-compiler:2.16'
然后Sync Now即可。原博主链接: 点击打开链接

猜你喜欢

转载自blog.csdn.net/fsc_fantexi/article/details/80859545