Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 5.0 - Intellij Gradle: Cannot resolve symbol: @color:material_blue_500

I am trying to customize the material design theme as suggested in this link : android dev

but when I add the following code to my v21/styles file Intellij says that it cannot resolve these symbols.

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" 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>

</resources>

I looked around to see if there are any particular settings that need to be done on the color side but nothing came up. I am using API 21 with support lib v7 on gradle.

like image 562
nathandrake Avatar asked Oct 20 '14 07:10

nathandrake


2 Answers

@color/material_blue_500 and others are not the resources in android library.

You must define the color resources in res/values/colors.xml by yourself.

such as <color name="material_blue_500">#5677fc</color>.

And then you can use it as <item name="colorPrimary">@color/material_blue_500</item>.

like image 147
Yong Avatar answered Sep 25 '22 13:09

Yong


Android docs are very vague on this, leading to confusion. To get the predefined colors copy color_material.xml to your local res/values dir. That file is a preserved version as it was during Android-L. The offical version which sits in your local directory:

...sdk/platforms/android-21/data/res/values/colors_material.xml

has been trimmed down to remove those color definitions.

like image 20
user3259330 Avatar answered Sep 25 '22 13:09

user3259330