【发布时间】:2022-06-18 06:36:57
【问题描述】:
当我在 Android Studio 中构建我的应用程序时,我收到“编译值文件失败”错误。当我追溯它时,我发现这是原因:> Task :app:mergeDebugResources /home/******/.gradle/caches/transforms-3/2b32a52804d1f1842c2b39552e0635b5/transformed/material-1.5.0/res/values/values.xml:203:4: Invalid <color> for given resource value.
当我在 values.xml 文件中找到错误所在的行时,是这样的:<bool name="mtrl_btn_textappearance_all_caps">true</bool>
我在研究此错误时尝试了“clean project”、“rebuild project”、“Run with --scan”,修复了所有警告,并根据建议的修复调整了 gradle.build 中的 compileAndroidSkd 级别,但没有建议的解决方案解决了错误。
我知道无法编辑 values.xml 文件中的值,因为它是 Android Studio 的一部分,而不是我的应用程序。所以,我想知道这个错误可能有什么解决方案。另外,我想知道将来参考,如果您可以在应用程序中覆盖 values.xml 中的值,那么不要更改原始 .xml 文件?
这是我的 gradle.build 代码:
Plugins {
id 'com.android.application'
}
机器人{ 编译SDK 31
defaultConfig {
applicationId "com.******.******"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
依赖{
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
【问题讨论】:
标签: android-studio sdk android-gradle-plugin