No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_light_text_pressed')

不想你离开。 提交于 2019-12-06 14:39:23

Inside the color.xml you can define colors as follows:

<?xml version="1.0" encoding="utf-8"?>
<resources>

<item name="blue" type="color">#FF33B5E5</item>
<item name="purple" type="color">#FFAA66CC</item>
<item name="green" type="color">#FF99CC00</item>
<item name="orange" type="color">#FFFFBB33</item>
<item name="red" type="color">#FFFF4444</item>
<item name="darkblue" type="color">#FF0099CC</item>
<item name="darkpurple" type="color">#FF9933CC</item>
<item name="darkgreen" type="color">#FF669900</item>
<item name="darkorange" type="color">#FFFF8800</item>
<item name="darkred" type="color">#FFCC0000</item>

<integer-array name="androidcolors">
    <item>@color/blue</item>
    <item>@color/purple</item>
    <item>@color/green</item>
    <item>@color/orange</item>
    <item>@color/red</item>
    <item>@color/darkblue</item>
    <item>@color/darkpurple</item>
    <item>@color/darkgreen</item>
    <item>@color/darkorange</item>
    <item>@color/darkred</item>
</integer-array>

This is happen because of you use color which is not included in your color.xml file.

Add color name and values in your both color files like below.

<color name="common_signin_btn_dark_text_pressed">SomeColorValue(Hash Code)</color>

Thanks all for your suggestions but unfortunately none of them worked. I finally solved the error by replacing the color sources in common_signin_button_text_light.xml with

<item android:state_pressed="true" android:color="@color/common_google_signin_btn_text_light_pressed" />
    <item android:state_focused="true" android:state_enabled="false" android:color="@color/common_google_signin_btn_text_light_disabled" />
    <item android:state_focused="true" android:color="@color/common_google_signin_btn_text_light_focused" />
    <item android:state_enabled="false" android:color="@color/common_google_signin_btn_text_light_disabled" />
    <item android:color="@color/common_google_signin_btn_text_light_default" />

and common_signin_button_text_dark.xml with

<item android:state_pressed="true" android:color="@color/common_google_signin_btn_text_dark_pressed" />
    <item android:state_focused="true" android:state_enabled="false" android:color="@color/common_google_signin_btn_text_dark_disabled" />
    <item android:state_focused="true" android:color="@color/common_google_signin_btn_text_dark_focused" />
    <item android:state_enabled="false" android:color="@color/common_google_signin_btn_text_dark_disabled" />
    <item android:color="@color/common_google_signin_btn_text_dark_default" />

It seems the resources files update after updating Android Studio.

I was able to successfully build my app after making above changes.

In color.xml you should declare color:-

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="common_singin_btn_light_text_pressed">#0288D1</color>
</resources>
Siena

Go to src\main\res\layout folder structure.

In XML, replace the string:

"android:textColor:@colour/common_google_signin_btn_text_light_focused" 

with:

android:textColor="#90000000".

Solved the issue for me

I came across the same problem when I was updating google-play-services_lib module, I've had in my project, to the newer version of Google Play Services.

Here is the screenshot of the structure to the common_colors.xml from the old google-play-services_lib where the common_signin_btn_dark_text_pressed is located:

And here is the content of the common_colors.xml:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <!-- Sign-in Button Colors -->
    <color name="common_signin_btn_dark_text_default">@android:color/white</color>
    <color name="common_signin_btn_dark_text_pressed">@android:color/white</color>
    <color name="common_signin_btn_dark_text_disabled">#FFAAAAAA</color>
    <color name="common_signin_btn_dark_text_focused">@android:color/white</color>
    <color name="common_signin_btn_light_text_default">#FF737373</color>
    <color name="common_signin_btn_light_text_pressed">@android:color/white</color>
    <color name="common_signin_btn_light_text_disabled">#FFAAAAAA</color>
    <color name="common_signin_btn_light_text_focused">#FF737373</color>
    <color name="common_signin_btn_default_background">#FFDD4B39</color>
    <color name="common_action_bar_splitter">#d2d2d2</color>
</resources>

So, basically, include that content in your res -> values -> colors.xml, and everything should work fine again!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!