5

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! :)

Kurtis92
  • 710
  • 1
  • 12
  • 34
  • Have you import the library and compile it with your project? Also make sure you run Rebuild Project if you are using Android Studio. – Anggrayudi H Jul 11 '15 at 22:26
  • I got this problem fixed by setting targetSdkVersion to 21 in my gradle build file, and changing `compile 'com.android.support:appcompat-v7:20.+'` to use `21.+`. I don't understand it though, so I don't know if it will work for you. Then you'll run into the problem of http://stackoverflow.com/questions/3963978/android-xml-files-why-do-predefined-colors-not-work-for-me – LarsH Aug 15 '15 at 16:26
  • See http://stackoverflow.com/questions/26431676/appcompat-v721-0-0-no-resource-found-that-matches-the-given-name-attr-andro – LarsH Aug 15 '15 at 16:30

1 Answers1

-3

Try

parent="android:Theme.AppCompat.Light"

Might also reference:

No resource found - Theme.AppCompat.Light.DarkActionBar

Community
  • 1
  • 1
GNewc
  • 445
  • 4
  • 4
  • Ok, I've followed the guide about "Adding libraries with resources" (https://developer.android.com/tools/support-library/setup.html#add-library), but I still got the same problem :( – Kurtis92 Nov 20 '14 at 15:28