【问题标题】:getting "Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurface</macro>'"获取 \"Can\'t determine type for tag \'<macro name=\"m3_comp_bottom_app_bar_container_color\">?attr/colorSurface</macro>\'\"
【发布时间】:2023-02-17 04:07:08
【问题描述】:

构建.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.4"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"

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

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

build.gradle(:应用程序)

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

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.northguide"
        minSdk 21
        targetSdk 32
        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'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
}

`

我收到错误:

“无法确定标签 '?attr/colorSurface' 的类型”

尝试在 Android Studio 中构建我的 android 项目时。

任何人都可以解释发生了什么以及如何解决这个问题。 我刚刚使用空活动创建了项目,并尝试运行该应用程序以确保所有内容都已同步,我得到了这个。我以前做过但是第一次遇到这样的错误。我不知道这是否是 Android Studio 更新中的错误。

【问题讨论】:

    标签: android kotlin


    【解决方案1】:

    我遇到了同样的问题,但我还没有完全研究为什么存在这个问题。我所能找到的是,主要的罪魁祸首是依赖项部分中的以下两行:

    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.7.0'
    

    您可以实施两种解决方案:

    1. 更新Android Studio版本到最新
    2. 降级这两个依赖的版本

      确实,解决方案 #1是最好的,但是解决方案#2为我工作(我没有时间升级和“可能处理新的未知问题”)。我降级如下:

      implementation 'androidx.appcompat:appcompat:1.4.1'
      implementation 'com.google.android.material:material:1.6.0'
      

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,就我而言,解决方案是更新安卓工作室最新版本(电鳗)。我也更新摇篮和所有依赖项它对我有用。

      干杯!

      【讨论】:

        猜你喜欢
        • 2022-11-07
        • 2022-11-06
        • 2022-11-05
        • 2022-11-04
        • 2011-04-27
        • 2017-01-10
        • 1970-01-01
        • 2021-11-30
        • 2022-12-27
        相关资源
        最近更新 更多