androidkotlinandroid-gradle-plugingradle-plugincredential-manager

Project file cannot get build


I am trying to make a very simple project to understand the topic of Google Credential Manager in android. But when I tried to launch my project in emulators (either UpsideDownCake or Vanilla) the app is not launching. and it is giving error in build time as ->

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).

I also tried using latest versions of dependencies but it is not working. I also tried changing from Vanilla to UpsideDownCake to launch in different android version it is not working. My code files are ->

  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(Project level)
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(app level)
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)
}

If any further files is required please let me know. I humbly request you help me to resolve the issue.


Solution

  • The issue you're encountering is related to the libraries you're using in your project requiring API level 35, but your project is compiled with API level 34, which is causing compatibility problems. Solution:

    1. Update compileSdkVersion 35
    2. Update targetSdkVersion 35
    3. Update Android Gradle Plugin (AGP) classpath 'com.android.tools.build:gradle:8.7.0'