Android Studio中的资源链接失败

kpbwa7wx  于 2023-04-21  发布在  Android
关注(0)|答案(2)|浏览(482)

我正在使用Android Studio,我正在尝试使用Google素材库
我收到以下错误(Android资源链接失败):
错误:AAPT:C:\Users\ANDRES\Desktop\cursillo_android\TipTime2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v31\values-v31.xml:3:错误:resource android:color/system_neutral1_1000 not found.
Mi等级文件为:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdk 30
    compileSdkVersion 30
    defaultConfig {
        applicationId "com.example.tiptime2"
        minSdk 24
        targetSdk 30
        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
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }

    buildFeatures {
        viewBinding = true
    }

}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'com.google.android.material:material:1.5.0-alpha05'

}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
        jcenter()

    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.3"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"

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

    }
}

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

我想与您分享错误的图片:

谢谢你

jyztefdp

jyztefdp1#

当您的targetSdk低于31时,与材料资源关联的支持库将与您的构建配置冲突。
在构建过程中,Gradle将使用一个任务来检查所有support .aar库元数据,其中设置了构建目标兼容性;在com.google.android.material:material:1.5.0-alpha 05’的情况下,目标兼容性被设置为高于30(可以是31,或者甚至更高);补救措施是:因此,从这里转到早期的材料支持库https://mvnrepository.com/artifact/com.google.android.material/material,以使用材料支持类的早期支持版本;

6vl6ewon

6vl6ewon2#

尝试在gradle(Module)中删除'implementation 'com.google.android.material:material:1.10.0-alpha 01 ',效果很好。

相关问题