Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android error: AAPT: error: resource color/colorPrimary not found

I upgraded my project ( Ionic Framework ) from Android to AndroidX. After that, my project started throwing errors while rebuilding. It is giving "AAPT: error: resource color/colorPrimary (aka io.aide.aide:color/colorPrimary) not found." from file "{Project}\android\app\src\main\res\values\styles.xml".

Here is my styles.xml file

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

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:background">@null</item>
    </style>


    <style name="AppTheme.NoActionBarLaunch" parent="AppTheme.NoActionBar">
        <item name="android:background">@drawable/splash</item>
    </style>
</resources>

The folder of styles.xml is as below

enter image description here

In the below post, they suggested to create a color file. Error:(387, 5) error: resource color/colorPrimary (aka com.example.kubix.r3vir3dv3:color/colorPrimary) not found

I am beginner and I do not know what should be in the color file.

Can any one give me any suggestions to overcome this problem?

like image 843
user1466508 Avatar asked Mar 09 '20 10:03

user1466508


Video Answer


1 Answers

In your project, you need to create color.xml file

Right click on values > New > Values Resource File > Enter File Name "color.xml"

Path:

 res/values/color.xml 

This is how your color.xml will look like:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">@color/blue_1</color>
    <color name="colorPrimaryDark">@color/blue_1</color>
    <color name="colorAccent">@color/blue_5</color>

    <color name="blue_1">#00101f</color>
    <color name="blue_5">#0078ff</color>

</resources>
like image 177
Waqar UlHaq Avatar answered Nov 07 '22 03:11

Waqar UlHaq