8

How to find issue to this error when I did a make I have got this error message : Error:(9, 5) error: resource android:attr/colorError not found

Thing strange I've 2 build.gradle files : Here my build.gradle (Project:Projectname) File :

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Here my build.gradle (Module:app) File :

apply plugin: 'com.android.application'
android {
    compileSdkVersion 22
    defaultConfig {
        applicationId "org.acme.nfcedit"
        minSdkVersion 22
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

This file appears /home/users/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/c41e5bc4d98504dc222d4eca88ab6d1b/res/values-v26/values-v26.xml content

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Base.Theme.AppCompat" parent="Base.V26.Theme.AppCompat"/>
    <style name="Base.Theme.AppCompat.Light" parent="Base.V26.Theme.AppCompat.Light"/>
    <style name="Base.V26.Theme.AppCompat" parent="Base.V26.Theme.AppCompat">
        <!-- We can use the platform styles on API 26+ -->
        <item name="colorError">?android:attr/colorError</item>
    </style>
    <style name="Base.V26.Theme.AppCompat.Light" parent="Base.V23.Theme.AppCompat.Light">
        <!-- We can use the platform styles on API 26+ -->
        <item name="colorError">?android:attr/colorError</item>
    </style>
    <style name="Base.V26.Widget.AppCompat.Toolbar" parent="Base.V7.Widget.AppCompat.Toolbar">
        <item name="android:touchscreenBlocksFocus">true</item>
        <item name="android:keyboardNavigationCluster">true</item>
    </style>
    <style name="Base.Widget.AppCompat.Toolbar" parent="Base.V26.Widget.AppCompat.Toolbar"/>
</resources>

I don't know what's mmeaning ?android:attr/colorError

Thanks

dubis
  • 378
  • 1
  • 7
  • 22
  • show your `build.gradle` – IntelliJ Amiya Nov 02 '17 at 18:09
  • I showed it it's my first file. In fact I have 2 build.gradle files : one with my (Projet: Edit) (see above) and one with my (module : app ) – dubis Nov 02 '17 at 18:20
  • Show your `build.gradle (module : app )` . – Muhammad Hannan Nov 02 '17 at 18:22
  • Hey @dubis did you get it to work? Having the same issue :/. – Abushawish Nov 07 '17 at 19:44
  • I copied all source in text files and I did a new project. I could compile an APK with a new build.gradle. – dubis Nov 07 '17 at 20:13
  • https://webapps.stackexchange.com/a/125095/186471 - try: `=NETWORKDAYS(TO_DATE(A2); TO_DATE(B2)) * (E2-D2) - IF(INDEX(SPLIT(A2; " "); 1; 2) > D2; D2 - INDEX(SPLIT(A2,;" "); 1; 2); ) - IF(INDEX(SPLIT(B2; " "); 1; 2) < E2; E2 - INDEX(SPLIT(B2; " "); 1; 2); )` - I am not allowed to reply there – player0 Mar 26 '20 at 11:25

3 Answers3

24

The attribute named "android:attr/colorError" is referenced by the appcompat library at API 26 and above. But the build is compiling with sdk version 22.

So, inside your app module's build.gradle, increase your compileSdkVersion to 26 to make it agree with the version of the appcompat library you are using.

In other words, right now, you have:

compileSdkVersion 22
implementation 'com.android.support:appcompat-v7:26.1.0'

But, those two versions should be in agreement. So, see what happens with:

compileSdkVersion 26
implementation 'com.android.support:appcompat-v7:26.1.0'
albert c braun
  • 2,650
  • 1
  • 22
  • 32
  • What if you want to compile at 22? Changing the appcompat to 22 doesn't seem to work. – Stephen M -on strike- Apr 05 '18 at 15:48
  • hi bro, i have my project in 26 but mi master branch have to 24.. so what doing ? – marlonpya Jul 05 '18 at 01:02
  • if you can set compileSdkVersion to 26 in your master branch, then i believe android:attr/colorError will be available for use. if that is not a possibility, then i would suggest trying to reduce the appcompat library version down to 24. – albert c braun Jul 05 '18 at 19:37
1

Change compileSdkVersion 22 to compileSdkVersion 26.

ttdevs
  • 101
  • 2
0

Here is an update for RN>0.60. Inside your android\build.gradle, place the following inside the allprojects block to ensure subprojects have an updated compileSdkVersion.

subprojects {
    afterEvaluate {
        project ->
            if (project.hasProperty("android")) {
                android {
                    compileSdkVersion = 28
                    buildToolsVersion = "28.0.3"
                }
            }
    }
}
Matt Booth
  • 1,723
  • 3
  • 13
  • 19