Error: Error: A resource was not found that matches the specified name: attr 'colorAccent'

I am studying Material Design, in particular, I want to configure my application with Material Design also for older versions of Android. I am reading this guide: https://developer.android.com/training/material/compatibility.html#SupportLib

About the color palette, the manual says:

To get the material styles and customize the color palette using the Android v7 support library, use one of 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: A resource was not found that matches the specified name: attr 'colorAccent'.

... same error for colorPrimaryDark and colorPrimary! If I ran this code in the values-v21 / style.xml file by placing the "android:" tag before the color Primary, colorPrimaryDark and colorAccent, like:

 <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 do not understand where I am mistaken :( I, of course, updated the v7 support library

Any help would be appreciated! :)

+5
source share
1 answer

Try

 parent="android:Theme.AppCompat.Light" 

You can also specify:

Resource not found - Theme.AppCompat.Light.DarkActionBar

-2
source

Source: https://habr.com/ru/post/1207254/


All Articles