android studio apt 不兼容插件,Android Studio 3.0报错:Error:android-apt plugin is incompatible with the Andr...

Android Studio 3.0执行android-apt报错:

Error:android-apt plugin is incompatible with the Android Gradle plugin.  Please use 'annotationProcessor' configuration instead.

原因及解决

Android Gradle 2.2插件集成了android-apt里的所有功能,从Android Gradle 2.3插件开始阻止android-apt的使用。同时android-apt官方停止维护,建议迁移到annotationProcessor。具体查看apt迁移通知From apt to annotationProcessor。

迁移方法

1、在build.gradle添加Android Gradle 3.0 插件

buildscript {

repositories {

...

google()

}

dependencies {

classpath 'com.android.tools.build:gradle:3.0.0'

}

}

2、删除build.gradle里android-apt 的相关配置

buildscript {

repositories {

...

google()

}

dependencies {

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

}

}

apply plugin: 'com.neenbedankt.android-apt'

3、替换build.gradle里旧的配置为新的配置

做以下替换

compile 改为 implementation,

apt 改为 annotationProcessor

testCompile 改为 androidTestImplementation

dependencies {

compile 'com.google.dagger:dagger:2.0'

apt 'com.google.dagger:dagger-compiler:2.0'

}

改为

dependencies {

implementation 'com.google.dagger:dagger:2.0'

annotationProcessor 'com.google.dagger:dagger-compiler:2.0'

}

4、清理缓存并重启Android Studio 3.0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值