升级到 Jetpack Compose 物料清单 2023.08.00 需要我将 targetSdk 更改为 34

Rom*_*man 5 android android-jetpack-compose

我正在使用撰写物料清单来管理项目中的撰写版本。我将 bom 版本更新为 2023:08:00,现在收到此错误:

An issue was found when checking AAR metadata:

1. Dependency 'androidx.emoji2:emoji2:1.4.0' requires libraries and applications that
   depend on it to compile against version 34 or later of the
   Android APIs.

   :app is currently compiled against android-33.

   Also, the maximum recommended compile SDK version for Android Gradle
   plugin 8.1.0 is 33.

   Recommended action: Update this project's version of the Android Gradle
   plugin to one that supports 34, then update this project to use
   compileSdk of at least 34.

   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).
Run Code Online (Sandbox Code Playgroud)

如何在不将compileSdk和targetSdk更改为34的情况下更新我的compose版本?

项目级别等级:

buildscript {
    ext {
        gradle_version = '8.1.0'
        kotlin_version = '1.9.0'
        ksp_version = '1.9.0-1.0.13'
        compose_bom_version = '2023.08.00'
        compose_compiler_version = '1.5.1'
        accompanist_version = '0.31.6-rc'
        hilt_version = '2.44.1'
        hilt_navigation_compose_version = '1.0.0'
        room_version = '2.5.2'
    }
}
plugins {
    id 'com.android.application' version "${gradle_version}" apply false
    id 'org.jetbrains.kotlin.android' version "${kotlin_version}" apply false
    id 'com.google.dagger.hilt.android' version "${hilt_version}" apply false
    id 'com.google.devtools.ksp' version "${ksp_version}" apply false
}
Run Code Online (Sandbox Code Playgroud)

应用程序级别等级:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.dagger.hilt.android'
    id 'com.google.devtools.ksp'
    id 'kotlin-kapt'
    id 'kotlin-parcelize'
}

android {
    namespace ''
    compileSdk 33

    defaultConfig {
        applicationId ""
        minSdk 29
        targetSdk 33
        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_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_compiler_version
    }
    packaging {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {
    
    implementation 'androidx.core:core-ktx:1.10.1'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
    implementation 'androidx.activity:activity-compose:1.7.2'
    implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"
    implementation "androidx.navigation:navigation-compose:2.6.0"

    // Hilt
    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
    implementation "androidx.hilt:hilt-navigation-compose:$hilt_navigation_compose_version"

    // Room
    implementation "androidx.room:room-runtime:$room_version"
    ksp "androidx.room:room-compiler:$room_version"

    // Jetpack Compose
    implementation platform("androidx.compose:compose-bom:$compose_bom_version")
    implementation "androidx.compose.ui:ui"
    implementation 'androidx.compose.ui:ui-graphics'
    implementation "androidx.compose.ui:ui-tooling-preview"
    implementation 'androidx.compose.material3:material3'
    implementation 'androidx.compose.material3:material3-window-size-class'
    debugImplementation "androidx.compose.ui:ui-tooling"
    debugImplementation "androidx.compose.ui:ui-test-manifest"

    // Accompanist
    implementation "com.google.accompanist:accompanist-navigation-animation:$accompanist_version"
    implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"

    // Splash
    implementation "androidx.core:core-splashscreen:1.0.1"

    // Test
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    androidTestImplementation platform("androidx.compose:compose-bom:$compose_bom_version")
    androidTestImplementation "androidx.compose.ui:ui-test-junit4"
}
Run Code Online (Sandbox Code Playgroud)

我尝试将 jetpack compose 物料清单版本更新到最新版本,而不必针对 android 14。

小智 3

同样的情况,我所做的只是将compileSdk和buildToolsVersion版本更改为34(和34.0.0)。这不需要您更改 targetSdk 版本。