前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >解决Android studio 2.3升级到Android studio 3.0 后apt报错问题

解决Android studio 2.3升级到Android studio 3.0 后apt报错问题

作者头像
程思扬
发布2022-01-10 14:43:44
6980
发布2022-01-10 14:43:44
举报
文章被收录于专栏:程思阳的专栏

今天从gaithub上下载了一个项目,一直提示apt报错,网上找了很久才找到答案,在这里给大家整理一下

1.现象描述

原来项目在Android studio 2.3一切正常,升级3.0之后报如下错误:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Error:Cannot choose between the following configurations of project :android_sdk: - debugApiElements - debugRuntimeElements - releaseApiElements - releaseRuntimeElements All of them match the consumer attributes: - Configuration 'debugApiElements' : - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required. - Configuration 'debugRuntimeElements' : - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required. - Configuration 'releaseApiElements' : - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required. - Configuration 'releaseRuntimeElements' : - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.

2.解决办法:

project的build.gradle文件中删除

?

1

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

module的build.gradle文件中删除

?

1

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

module的build.gradle文件中替换

?

1 2

//apt 'com.jakewharton:butterknife-compiler:8.0.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'

ps:下面再给大家补充介绍android studio更新到3.0后,不支持apt问题

android studio更新到3.0后,不支持apt了,适配仅需要修改以下两点:

1.移除module目录下的build.gradle中的 apply plugin: 'android-apt'

2.将apt改成annotationProcessor

例如:

?

1

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

改成

?

1

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

总结

以上所述是我给大家介绍的解决Android studio 2.3升级到Android studio 3.0 后apt报错问题,希望对大家有所帮助,如果大家有任何疑问请给我留言,我会及时回复大家的。在此也非常感谢大家对我的支持!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018/06/20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档