Android Build AAPT error: style attribute ‘attr/colorPrimary’ not found

  • by

I recently encountered an error on my newly build Android project which was saying:

Error:
AAPT: error: style attribute ‘attr/colorPrimary’ not found

Solution:
Somehow while creating project it missed appcompat implementation in build.gradle(app)
implementation ‘com.android.support:appcompat-v7:28.0.0’

After adding this implementation my project worked fine. Also please be sure you are using the right version of appcompat for your project.

My build.gradle (after adding implementation in the dependencies)
build.gradle (app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.0"

    defaultConfig {
        applicationId "parallelcodes.csvreader"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
       release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
       }
    }

}

dependencies {
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])

}

Thank You.