Android Studio doesn't find color style resource
I'm trying to target with Theme.AppCompat.NoActionBar but the IDE throws
error named resources cannot find. Please help. Any help would be greatly appreciated.
Styles.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowActionBar">false</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorPrimaryLight">@color/primary_light</item>
<item name="colorAccent">@color/accent</item>
<item name="textColorPrimary">@color/primary_text</item>
<item name="textColorSecondary">@color/secondary_text</item>
<item name="iconColor">@color/icons</item>
<item name="dividerColor">@color/divider</item>
</style>
</resources>
The .xml color looks like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary">#FF9800</color>
<color name="primary_dark">#F57C00</color>
<color name="primary_light">#FFE0B2</color>
<color name="accent">#03A9F4</color>
<color name="primary_text">#212121</color>
<color name="secondary_text">#727272</color>
<color name="icons">#212121</color>
<color name="divider">#B6B6B6</color>
</resources>
Just Next . Build > Clean Project
File > Invalidate Caches / Restart Project
Rename xml name, set color.xml
instead colors.xml
to values ββfolder. Then Then . Build > Clean Project
Restart Project
Or try this way
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color name="green">#00ff00</color>
Link
I got the following error which seems similar to yours
error: resource color / color_primary (aka com.example.android.test31july: color / color_primary) was not found.
I went to colors.xml and created exactly a color resource named "color_primary" and the problem went away.
Recovery can take a long time.
Just remove the offending line and add it again.
make sure you are using a colored label instead of any other label.
<color name="name">#123</color>
Make sure you don't have imports like mine below
import android.R
This is importing the wrong resource.