项目文件无法构建

问题描述 投票:0回答:1

我正在尝试制作一个非常简单的项目来理解android中Google Credential Manager的主题。但是,当我尝试在模拟器(UpsideDownCake 或 Vanilla)中启动我的项目时,应用程序未启动。它在构建时间中给出错误 ->

5 issues were found when checking AAR metadata:
  1.  Dependency 'androidx.credentials: credentials- play- services- auth: 1. 5. 0- alpha04'  requires libraries and applications that       depend on it to compile against version 35 or later of the       Android APIs.
      :app is currently compiled against android-34.
      Also, the maximum recommended compile SDK version for Android Gradle       plugin 8.5.2 is 34.
      Recommended action: Update this project's version of the Android Gradle       plugin to one that supports 35, then update this project to use       compileSdk of at least 35.
      Note that updating a library or application's compileSdk (which       allows newer APIs to be used) can be done separately from updating       targetSdk (which opts the app in to new runtime behavior) and       minSdk (which determines which devices the app can be installed       on).
  2.  Dependency 'androidx.credentials: credentials: 1. 5. 0- alpha04'  requires libraries and applications that       depend on it to compile against version 35 or later of the       Android APIs.
      :app is currently compiled against android-34.
      Also, the maximum recommended compile SDK version for Android Gradle       plugin 8.5.2 is 34.
      Recommended action: Update this project's version of the Android Gradle       plugin to one that supports 35, then update this project to use       compileSdk of at least 35.
      Note that updating a library or application's compileSdk (which       allows newer APIs to be used) can be done separately from updating       targetSdk (which opts the app in to new runtime behavior) and       minSdk (which determines which devices the app can be installed       on).
  3.  Dependency 'androidx.biometric: biometric- ktx: 1. 4. 0- alpha02'  requires libraries and applications that       depend on it to compile against version 35 or later of the       Android APIs.
      :app is currently compiled against android-34.
      Also, the maximum recommended compile SDK version for Android Gradle       plugin 8.5.2 is 34.
      Recommended action: Update this project's version of the Android Gradle       plugin to one that supports 35, then update this project to use       compileSdk of at least 35.
      Note that updating a library or application's compileSdk (which       allows newer APIs to be used) can be done separately from updating       targetSdk (which opts the app in to new runtime behavior) and       minSdk (which determines which devices the app can be installed       on).
  4.  Dependency 'androidx.biometric: biometric: 1. 4. 0- alpha02'  requires libraries and applications that       depend on it to compile against version 35 or later of the       Android APIs.
      :app is currently compiled against android-34.
      Also, the maximum recommended compile SDK version for Android Gradle       plugin 8.5.2 is 34.
      Recommended action: Update this project's version of the Android Gradle       plugin to one that supports 35, then update this project to use       compileSdk of at least 35.
      Note that updating a library or application's compileSdk (which       allows newer APIs to be used) can be done separately from updating       targetSdk (which opts the app in to new runtime behavior) and       minSdk (which determines which devices the app can be installed       on).
  5.  Dependency 'androidx.core:core: 1. 15. 0- alpha01'  requires libraries and applications that       depend on it to compile against version 35 or later of the       Android APIs.
      :app is currently compiled against android-34.
      Also, the maximum recommended compile SDK version for Android Gradle       plugin 8.5.2 is 34.
      Recommended action: Update this project's version of the Android Gradle       plugin to one that supports 35, then update this project to use       compileSdk of at least 35.
      Note that updating a library or application's compileSdk (which       allows newer APIs to be used) can be done separately from updating       targetSdk (which opts the app in to new runtime behavior) and       minSdk (which determines which devices the app can be installed       on).

我也尝试使用最新版本的依赖项,但它不起作用。我还尝试从 Vanilla 更改为 UpsideDownCake 以在不同的 Android 版本中启动,但它不起作用。 我的代码文件是 ->

  1. libs.version.toml
[versions]
agp = "8.5.2"
kotlin = "2.0.10"
coreKtx = "1.13.1"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
lifecycleRuntimeKtx = "2.8.4"
activityCompose = "1.9.1"
composeBom = "2024.04.01"
navigationCompose = "2.8.0-beta06"
credentials = "1.5.0-alpha04"
kotlinSerialization = "1.6.3"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-compose-navigation = { group = "androidx.navigation", name = "navigation-compose", version.ref="navigationCompose"}
androidx-credentials-core = { group = "androidx.credentials", name = "credentials", version.ref = "credentials" }
# Optional - needed for credentials support from play services, for Android 13 and below.
androidx-credentials-compat = { group = "androidx.credentials", name = "credentials-play-services-auth", version.ref = "credentials" }
# Added for non-deprecated LocalLifecycleOwner
androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycleRuntimeKtx" }
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinSerialization" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
jetbrains-kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
  1. Build.gradle(项目级别)
plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.jetbrains.kotlin.android) apply false
    alias(libs.plugins.compose.compiler) apply false
}
  1. Build.gradle(应用程序级别)
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.jetbrains.kotlin.android)
    alias(libs.plugins.compose.compiler)
    alias(libs.plugins.jetbrains.kotlin.serialization)
}

android {
    namespace = "com.example.credentialmanagerdemo"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.example.credentialmanagerdemo"
        minSdk = 24
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

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

    buildTypes {
        release {
            isMinifyEnabled = 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 {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.1"
    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }
}

dependencies {

    implementation(libs.androidx.compose.navigation)
    implementation(libs.androidx.credentials.core)
    implementation(libs.androidx.credentials.compat)
    implementation(libs.androidx.lifecycle.runtime.compose)
    implementation(libs.kotlinx.serialization.json)

    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.lifecycle.runtime.ktx)
    implementation(libs.androidx.activity.compose)
    implementation(platform(libs.androidx.compose.bom))
    implementation(libs.androidx.ui)
    implementation(libs.androidx.ui.graphics)
    implementation(libs.androidx.ui.tooling.preview)
    implementation(libs.androidx.material3)
    testImplementation(libs.junit)
    androidTestImplementation(libs.androidx.junit)
    androidTestImplementation(libs.androidx.espresso.core)
    androidTestImplementation(platform(libs.androidx.compose.bom))
    androidTestImplementation(libs.androidx.ui.test.junit4)
    debugImplementation(libs.androidx.ui.tooling)
    debugImplementation(libs.androidx.ui.test.manifest)
}

如果需要任何其他文件,请告诉我。我恳请您帮我解决这个问题。

android kotlin android-gradle-plugin gradle-plugin credential-manager
1个回答
0
投票

您遇到的问题与您在需要 API 级别 35 的项目中使用的库有关,但您的项目是使用 API 级别 34 编译的,这会导致兼容性问题。 解决方案:

  1. 更新compileSdkVersion 35
  2. 更新targetSdkVersion 35
  3. 更新 Android Gradle 插件 (AGP) 类路径'com.android.tools.build:gradle:8.7.0'
© www.soinside.com 2019 - 2024. All rights reserved.