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.


  1. Base64Encode.io - Realtime Encode your string to Base64 format.
  2. Base64Decode.io - Realtime Decode Base64 data to plain text.
  3. Md5Hash.io - Realtime Encoding in Md5Hash.