AAPT: error: resource android:attr/fontVariationSettings not found.
安装sdk api28,安卓9.0
配置:
build.gradle(module:app)
apply plugin: 'com.android.application' android { compileSdkVersion 28 buildToolsVersion "36.1.0" defaultConfig { applicationId "com.example.myapplication" minSdkVersion 26 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 fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.material:material:1.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' } configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support') { // 强制所有support库使用 27.1.1(匹配你的低SDK) if (!requested.name.startsWith("multidex")) { details.useVersion '26.2.0' } } } }
点击sync project with gradle files

点击运行:

----------------------
打开你项目的 build.gradle (Module 级别) 文件(不是 Project 级别),修改以下 3 个版本号:
gradle
android {
// 1. 把 compileSdkVersion 改成至少 28 及以上
compileSdkVersion 28
defaultConfig {
// 2. targetSdkVersion 也同步改成 28 及以上
targetSdkVersion 28
}
}
dependencies {
// 3. 把 support 库统一升级到 28.0.0 (和compileSdkVersion匹配)
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
// 其他所有 support 库都统一为 28.0.0
}
关键说明
core-1.0.1是 AndroidX 库,最低要求 compileSdkVersion ≥ 28- 低版本 SDK(27 及以下)没有
fontVariationSettings属性,所以报错 - 必须保证:compileSdkVersion ≥ 依赖库的最低要求版本
欢迎讨论,相互学习。
cdtxw@foxmail.com

浙公网安备 33010602011771号