如何查找问题Android SDK 3.0错误:(9,5)错误:未找到资源android:attr/colorError
在执行make时,如何找到此错误的问题,我收到以下错误消息: 错误:(9,5)错误:未找到资源android:attr/colorError
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
奇怪的是,我有2个build.gradle文件: 这是我的build.gradle(Project:Projectname)文件:
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
}
这是我的build.gradle(Module:app)文件:
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'
}
此文件显示/home/users/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/c41e5bc4d98504dc222d4eca88ab6d1b/res/values-v26/values-v26.xml内容>
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>
我不知道什么是?android:attr/colorError
谢谢
API 26和更高版本的appcompat库引用了名为"android:attr/colorError"的属性.但是该构建是使用sdk 22版进行编译的.
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.
因此,在您的应用程序模块的build.gradle中,将您的compileSdkVersion增加到26,以使其与您正在使用的appcompat库的版本一致.
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'