9

I have switched to android studio 3. after many problem that I fixed, I got this error:

color/colorPrimary but i go this error:Error:(87, 5) error: expected color but got (raw string) color/gray

enter image description here

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Nawrez
  • 3,314
  • 8
  • 28
  • 42

2 Answers2

21

You forgot to add @ before color/colorPrimary

change it like @color/colorPrimary

sample code

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>

    </style>
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

Color value should be a hex color code like #A5D3F4 OR a color reference with @ sign, like @color/colorPrimary. before use these reference, you must create resources like res/values/color.xml.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#6200EE</color>
    <color name="colorPrimaryDark">#3700B3</color>
    <color name="colorAccent">#03DAC5</color>
    <color name="LabelColor_text_50">#FFFFFF</color>
    <color name="ValueColor_text_50">#333322</color>
    <color name="LabelColor_bg_50">#A5D3F4</color>
    <color name="ValueColor_bg_50">#E6EEF4</color>
</resources>

And use these name as <item name="someName">@color/LabelColor_text_50</item>

Mr. Mak
  • 837
  • 1
  • 11
  • 25