error: Error: No resource found that matches the given name: attr 'colorAccent'

Kurtis92 picture Kurtis92 · Nov 19, 2014 · Viewed 13.1k times · Source

I'm learning Material Design, in particular I want to customize my app with Material Design also for the older Android versions. I'm reading this guide: https://developer.android.com/training/material/compatibility.html#SupportLib

About Color Palette, the guide says:

To obtain material design styles and customize the color palette with the Android v7 Support Library, apply one of the Theme.AppCompat themes:

<!-- extend one of the Theme.AppCompat themes -->
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
    <!-- customize the color palette -->
    <item name="colorPrimary">@color/material_blue_500</item>
    <item name="colorPrimaryDark">@color/material_blue_700</item>
    <item name="colorAccent">@color/material_green_A200</item>
</style>

When I try to run this code, I got this error:

error: Error: No resource found that matches the given name: attr 'colorAccent'.

...and the same error for colorPrimaryDark and colorPrimary! If I run this code into the values-v21/style.xml file, putting the " android: " tag before colorPrimary, colorPrimaryDark and colorAccent, as:

<item name="android:colorPrimary">@color/material_blue_500</item>
<item name="android:colorPrimaryDark">@color/material_blue_700</item>
<item name="android:colorAccent">@color/material_green_A200</item>

it works!

So...I don't understand where I'm wrong :( I've surely updated the v7 support library

Any help will be appreciated! :)

Answer

GNewc picture GNewc · Nov 19, 2014

Try

parent="android:Theme.AppCompat.Light"

Might also reference:

No resource found - Theme.AppCompat.Light.DarkActionBar