簡體   English   中英

為什么我的 styles.xml 文件 (Android Studio) 中出現“Android 資源鏈接失敗”

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM