[英]Why am I getting “Android resource linking failed” in my styles.xml file (Android Studio)
嗨,我在 Android Studio 工作,并尝试为我的启动画面创建一个背景,该背景使用我的“rideshare_splash”图像作为背景,正如我在这个时间戳上一直在关注的教程中一样( https://youtu.be/144TuYxEu2M ?t=572 )但是当我 go 构建时,我收到一条错误消息,提示“Android 资源链接失败”。
我在这里查看了类似标题的线程,但最相关的线程建议使用attr 名称而不是因为它已经过时而不起作用,然后我尝试了使用android:colorPrimary的建议,但这也没有帮助所以我想我会尝试问我自己的问题。
styles.xml代码
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
错误消息(从构建控制台复制并粘贴)
What went wrong:
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\mecha\AndroidStudioProjects\FYP_RideShareApp\app\src\main\res\values\styles.xml:4:5-8:13: AAPT: error: resource color/colorPrimary (aka codebymech.fyprideshareapp:color/colorPrimary) not found.
C:\Users\mecha\AndroidStudioProjects\FYP_RideShareApp\app\src\main\res\values\styles.xml:4:5-8:13: AAPT: error: resource color/colorPrimaryDark (aka codebymech.fyprideshareapp:color/colorPrimaryDark) not found.
C:\Users\mecha\AndroidStudioProjects\FYP_RideShareApp\app\src\main\res\values\styles.xml:4:5-8:13: AAPT: error: resource color/colorAccent (aka codebymech.fyprideshareapp:color/colorAccent) not found.
额外的信息
我的想法是本教程使用@color/coolorPrimary(以及colorPrimaryDark和colorAccent)的方式有问题,或者本教程中的某些内容可能已经过时了,因为它已经有几个月的历史了?
Also a side note: when I opened Android Studio there was no styles.xml only colors, strings and themes.xml files so I had to add my own styles.xml file to follow as the tutorial was doing so maybe that has had an effect ?
I think your colors.xml file does not containg these colors(colorPrimary, colorPrimaryDark and colorAccent) You have to define these colors in your color.xml file.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.