提问人:eC Droid 提问时间:4/28/2019 最后编辑:Zoe is on strikeeC Droid 更新时间:11/17/2023 访问量:26679
错误:资源 android:attr/colorError 未找到
error: resource android:attr/colorError not found
问:
将我的 compileSdkVersion、TargetSdkVersion 和库版本升级到 28 后。我的项目将不再生成。我目前是专门为“mFlavor”构建的,所以请忽略其他口味。Manaul 命令gradlew assembleMFlavorDebug
这是我的build.gradle(项目级别)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven {url 'https://maven.fabric.io/public'}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
/*classpath 'com.google.gms:google-services:3.1.1'*/
classpath 'com.google.gms:google-services:4.2.0'
// classpath 'com.google.gms:google-services:2.0.0-alpha3'
classpath 'io.fabric.tools:gradle:1.25.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://maven.google.com"}
maven{url "https://jitpack.io"}
google()
jcenter()
}
}
这是我的build.gradle(应用级别)
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories{
maven {url 'https://maven.fabric.io/public'}
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file('keystore.properties')
// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()
// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
flavorDimensions "default"
buildToolsVersion '28.0.3'
compileSdkVersion 28
defaultConfig {
targetSdkVersion 27
versionCode 19
versionName "1.0"
// If you have different applicationIds for buildTypes or productFlavors uncomment this block.
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": android.defaultConfig.applicationId]
}
}
vectorDrawables.useSupportLibrary = true
/*resConfigs "en", "ar"*/
}
buildTypes {
release {
// remove unused resources
shrinkResources true
// remove unused code
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
jniDebuggable false
//signingConfig signingConfigs.config
renderscriptDebuggable false
zipAlignEnabled true
}
debug {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
//checkReleaseBuilds false
disable 'MissingTranslation'
disable 'ExtraTranslation'
}
/*aaptOptions{
cruncherEnabled = false
}*/
productFlavors {
tFLavor {
compileSdkVersion 22
applicationId "com.tyu"
versionName "1.0.0"
versionCode 20
}
oFlavor {
compileSdkVersion 22
applicationId "com.op"
versionName = "1.2.0"
}
mFlavor {
minSdkVersion 16
compileSdkVersion 28
targetSdkVersion 28
applicationId "pk.com.mnb"
versionName = "4.0.2"
versionCode = 55
}
wFlavor {
minSdkVersion 14
compileSdkVersion 22
applicationId "com.wer"
versionName = "1.0"
versionCode = 1
}
uFlavor {
compileSdkVersion 22
applicationId "com.uio"
versionName = "1.0"
}
zFlavor {
minSdkVersion 14
compileSdkVersion 26
targetSdkVersion 26
applicationId "com.abc"
versionName = "1.0.2"
versionCode = 4
}
motoFlavor {
minSdkVersion 14
compileSdkVersion 25
targetSdkVersion 25
applicationId "pk.com.xyz"
versionName = "2.2.2"
versionCode = 26
}
}
//compileSdkVersion 27
}
repositories{
mavenCentral()
mavenLocal()
flatDir{
dirs '/src/mnb/libs', '/src/zxc/libs'
}
}
//def AAVersion = "4.4.0"
def AAVersion = "4.5.2"
dependencies {
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
implementation "org.androidannotations:androidannotations-api:$AAVersion"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
// compile 'com.android.support:cardview-v7:23.1.1'
implementation 'com.android.support:support-v13:28.0.0'
/*implementation 'com.intuit.sdp:sdp-android:1.0.6'*/
implementation 'com.google.code.gson:gson:2.8.0'
// implementation 'com.google.code.gson:gson:2.8.0'
// compile files('libs/activeandroid-3.1-beta.jar')
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
/* implementation 'com.google.android.gms:play-services-analytics:11.0.0'*/
//implementation 'com.android.support:multidex:1.0.1'
/*compile 'com.google.zxing:core:3.0.1'*/
/* compile files('libs/android-core-3.2.1.jar')
compile files('libs/core-3.2.1.jar') */
implementation 'net.hockeyapp.android:HockeySDK:5.1.0'
implementation 'com.facebook.android:facebook-android-sdk:4.6.0'
implementation('com.github.chrisbanes:PhotoView:1.3.0') {
exclude module: 'support-v4'
}
//mobilinkCompile 'com.facebook.android:facebook-android-sdk:4.14.0@aar'
uFlavorImplementation('com.twitter.sdk.android:twitter:2.2.0@aar') {
transitive = true
exclude module: 'support-v4'
}
implementation 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
implementation 'com.google.firebase:firebase-core:16.0.8'
}
apply plugin: 'com.google.gms.google-services'
这是我的gradle构建错误日志
E:\Personal\ProjectName\app\build\intermediates\incremental\mergeFlavorNameDebugResources\merged.dir\values-v26\values-v26.xml:7: error: resource android:attr/colorError not found.
E:\Personal\ProjectName\app\build\intermediates\incremental\mergeFlavorNameDebugResources\merged.dir\values-v26\values-v26.xml:11: error: resource android:attr/colorError not found.
E:\Personal\ProjectName\app\build\intermediates\incremental\mergeFlavorNameDebugResources\merged.dir\values-v26\values-v26.xml:15: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
E:\Personal\ProjectName\app\build\intermediates\incremental\mergeFlavorNameDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
E:\Personal\ProjectName\app\build\intermediates\incremental\mergeFlavorNameDebugResources\merged.dir\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\design-28.0.0.aar\51e52ea0f459299746be071f693e7a44\res\values\values.xml: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/keyboardNavigationCluster not found.
C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/fontStyle not found.
C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/font not found.
C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/fontWeight not found.
C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Command: C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\6d9ed65b6dd5edf0927b82048b67f6e3\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
D:\AndroidSDK\platforms\android-25\android.jar\
--manifest\
E:\Personal\ProjectName\app\build\intermediates\merged_manifests\FlavorNameDebug\processFlavorNameDebugManifest\merged\AndroidManifest.xml\
-o\
E:\Personal\ProjectName\app\build\intermediates\processed_res\FlavorNameDebug\processFlavorNameDebugResources\out\resources-FlavorNameDebug.ap_\
-R\
@E:\Personal\ProjectName\app\build\intermediates\incremental\processFlavorNameDebugResources\resources-list-for-resources-FlavorNameDebug.ap_.txt\
--auto-add-overlay\
--java\
E:\Personal\ProjectName\app\build\generated\not_namespaced_r_class_sources\FlavorNameDebug\processFlavorNameDebugResources\r\
--custom-package\
com.ooredoo.ProjectName\
-0\
apk\
--output-text-symbols\
E:\Personal\ProjectName\app\build\intermediates\symbols\FlavorName\debug\R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
答:
27赞
Izabela Orlowska
4/30/2019
#1
您的 SDK 版本编译为 25,但您(或您依赖的库)使用仅在 API 28 中添加的资源。更新文件以使用最新的编译 SDK 版本:build.gradle
android {
compileSdkVersion 28
...
}
评论
0赞
eC Droid
4/30/2019
请看 已经有mFlavor { minSdkVersion 16 compileSdkVersion 28 targetSdkVersion 28 applicationId "pk.com.mnb" versionName = "4.0.2" versionCode = 55 }
2赞
Izabela Orlowska
4/30/2019
例如,您在所有风格中都覆盖了它。删除重写,仅使用原始 compileSdkVersion。motoFlavor { ... compileSdkVersion 25 ... }
0赞
eC Droid
5/1/2019
单击 Make Project(Hammer 图标)是否编译并构建所有风格?
0赞
eC Droid
5/1/2019
Iazabella,你是对的,非常感谢。从其他 falvors 中删除 compileSdkVersion 确实解决了这个问题。但这很奇怪,因为我还尝试了 gradlew assembleMFlavor 告诉 gradle 只使用 compileSdkVersion 28 构建特定风格,但它仍然产生错误。你知道为什么吗?
1赞
Izabela Orlowska
5/1/2019
锤子图标应该构建所有。至于第二个问题,我不确定为什么会这样,也许它试图在某些子集中找到最小的编译SdkVersion?
0赞
Sreedhu Madhu
11/10/2023
#2
问题是您的 compileSDKVersion 与库的 compileSDKVersion 不匹配。使用下面的代码也可以为库覆盖它。
android/build.gradle
subprojects {
afterEvaluate {
project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion = 33
buildToolsVersion = "30.0.3"
}
}
}
}
评论