問題描述
今天在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
插件