android模块编译错误,android studio编译出错:Android resource linking failed

问题描述

今天在Android studio通过模拟器运行app的时候,出现了以下错误:

3dc82085a42dc58ccf1b7c1aa4a199d2.png

Android resource linking failed

AAPT: D:\developer\androidproject\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.

D:\developer\androidproject\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.

D:\developer\androidproject\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2781: error: resource android:attr/fontVariationSettings not found.

D:\developer\androidproject\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2782: error: resource android:attr/ttcIndex not found.

D:\developer\androidproject\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3207: error: resource android:attr/textFontWeight not found.

error: failed linking references.

提示Android resource linking failed,error: failed linking references。

问题排查

这种情况一般是项目配置导致的,打开 File–> Project Structure,看到modules选项内容如下:

681d2b9fed2de9747c811ecbd5e0891f.png

在上图中会发现compile sdk version 和build tools version版本不一致,将build tools version版本也改为26.

如下图所示:

02f12616cbb7f80f09cb58e18abdccfc.png

再次运行成功。

有时候修改了上述配置后,还会遇到“Android resource linking failed”的错误,但是,仔细看构建信息,可能还会遇到另外一种错误,如下图标记所示:

8c72146223df1ba29bc89a1b65c91e2e.png

错误内容是:

The specified Android SDK Build Tools version (26.0.0) is ignored, as it is below the minimum supported version (29.0.2) for Android Gradle Plugin 4.0.1.

这个就涉及到Android gradle插件了,具体的可参考官网,找到相匹配的版本。

c2e49ccdf9fd3e8db74eb184481c8d64.png

网址是:

https://developer.android.google.cn/studio/releases/gradle-plugin?hl=zh_cn

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值