nabia saroosh nabia saroosh - 4 months ago 62
Android Question

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

I am getting an error in style.xml

Error:(4, 5) No resource found that matches the given name (at 'colorPrimary' with value '@color/colorPrimary').

style.xml

<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>


</style>


anybody can tell me, what is problem behind of it?

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<!--<resources>-->
<!--<color name="colorPrimary">#3F51B5</color>-->
<!--<color name="colorPrimaryDark">#303F9F</color>-->
<!--<color name="colorAccent">#FF4081</color>-->
<!-- -->
<!--</resources>-->



<resources>
<color name="ColorPrimary">#3F51B5</color>
<color name="ColorPrimaryDark">#303F9F</color>
<color name="colorAccent">#ff40af</color>
<color name="textColorPrimary">#FFFFFF</color>
<color name="windowBackground">#FFFFFF</color>
<color name="navigationBarColor">#000000</color>
<color name="blue">#0051ff</color>

</resources>

Answer

Your colorPrimary is differ.

<item name="colorPrimary">@color/colorPrimary</item>

Change it to.

<item name="colorPrimary">@color/ColorPrimary</item>

As per your XML file.

EDIT 1

Same change for all the colors as per your colors.xml file.

<item name="colorPrimary">@color/ColorPrimary</item>
<item name="colorPrimaryDark">@color/ColorPrimaryDark</item>