简体   繁体   English

尝试使用 Android 材料3 时出现未解决的参考错误

[英]Getting Unresolved reference error while trying to work with Android material3

I am getting the below unresolved reference error while trying to build a new Android app using Jetpack Compose and Material3 components.我在尝试使用 Jetpack Compose 和 Material3 组件构建新的 Android 应用程序时遇到以下未解决的参考错误。

在此处输入图像描述

I have so far tried the below steps mentioned in this page:到目前为止,我已经尝试了本页中提到的以下步骤:

  1. Updated dependency of android.material to 1.5.04 or later将 android.material 的依赖关系更新到 1.5.04 或更高版本
  2. Ensured compileSDK is 31确保 compileSDK 为 31
  3. Ensure comilation with JAVA 8确保与 JAVA 8 编译
  4. Used AppCompatActivity to extend my MainActivity使用 AppCompatActivity 扩展我的 MainActivity
  5. Invalidated caches and restarted无效的缓存并重新启动

My gradle code is below:我的 gradle 代码如下:

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

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.example.recoverme"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    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'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion '1.5.21'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.6.0-alpha01'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.4.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
}

Any help in resolving this will be greatly appreciated.解决此问题的任何帮助将不胜感激。 I have been at it since yesterday.从昨天开始我就一直在做。

You are missing你不见了

implementation "androidx.compose.material3:material3:1.0.0-alpha02"

in your build.gradle.在您的 build.gradle 中。

Latest material3 release 最新材料3发布

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Material3 的 ScaffoldState 的未解决参考错误 - Unresolved Reference error for ScaffoldState with Material3 Jetpack Compose Android 项目中的 Material3 导入错误 - Import error for Material3 in Jetpack Compose Android Project 在 flutter 应用程序中实现本机 Kotlin 代码时出现“未解决的参考:android”错误 - Getting “unresolved reference: android” error while implementing native Kotlin code in flutter app 此材料 API 是实验性的,将来可能会更改或被删除。 使用新材料3卡时android报错 - This material API is experimental and is likely to change or to be removed in the future. error in android when using new material3 card Material3复选框android无法自定义按钮 - Material3 checkbox android cannot customize button Android 点击 Material3 切换黑暗模式 - Android Material3 toggle dark mode on click 显示此错误 - 获取未解决的参考 - Showing this error - Getting Unresolved reference 无法在 android compose Material3 中使用 rememberScaffoldState() - Not able to use rememberScaffoldState() in android compose Material3 在应用程序中,我不断收到 UNRESOLVED REFERENCE 错误:ANDROID - In the app, I keep getting error in UNRESOLVED REFERENCE: ANDROID 在 android 中生成签名 apk 时未解决的参考错误 - unresolved reference error while generating signed apk in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM