Invalid <color> for given resource value

Viewed 1086

I always get the following error when building:

Invalid <color> for given resource value.
Failed to compile values file.

My colors.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="Eins">#ffd700</color>
    <color name="Zwei">#000088</color>
    <color name="Drei">#fe0000</color>
    <color name="Vier">#8800ff</color>
    <color name="Funf">#008800</color>
    <color name="Sechs">#ff00ff</color>
    <color name="Sieben">#00ff00</color>
    <color name="Acht">#0088ff</color>
</resources>

I always called it with

resources.getColor(R.color.Sieben)

It worked the whole time, I didn't change anything, but suddenly it doesn't work anymore

I have copied the contents of the file several times into new files, the error is always in the same place

2 Answers

if you not see the icon from this color is something rung with this color code

In my case there was double quote before @ in color resource declaring

<color name="some_color">"@color/text_01</color>

At the same time gradle warning pointed to other colors started "s", and didn't point to broken one. Fixing color resource resolved the problem.

Related