android studio编译出错:Android resource linking failed

问题描述

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

在这里插入图片描述

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

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

问题排查

这种状况通常是项目配置致使的,打开 File–> Project Structure,看到modules选项内容以下:

在这里插入图片描述
在上图中会发现compile sdk version 和build tools version版本不一致,将build tools version版本也改成26.
以下图所示:
在这里插入图片描述
再次运行成功。



gradle

有时候修改了上述配置后,还会遇到“Android resource linking failed”的错误,可是,仔细看构建信息,可能还会遇到另一种错误,以下图标记所示:
在这里插入图片描述
错误内容是:

ui

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.google

这个就涉及到Android gradle插件了,具体的可参考官网,找到相匹配的版本。
在这里插入图片描述
spa

网址是:
https://developer.android.google.cn/studio/releases/gradle-plugin?hl=zh_cn
插件

相关文章
相关标签/搜索