androidkotlin-multiplatform

Kotlin Multiplatform Mobile targetSdk deprecated


I set up my build.gradle.kts file in the shared module of my KMM project like the following snippets shows:

android {
    namespace = "com.my.project"
    compileSdk = 33

    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdk = 24
        targetSdk = 33
    }
}

For the targetSDK I get the following warning:

targetSdk: Int?' is deprecated. Will be removed from library DSL in v9.0

How can I migrate this part and set the targetSdk version appropriately in my KMM project for the Android project?


Solution

  • The targetSdk property in the Android library Gradle plugin ("com.android.library") has been deprecated. As it is an advisory property, you can safely remove it from your configuration. The minSdk property alone is sufficient. Refer to the LibraryBaseFlavor reference for the deprecation message.

    Note: Do not confuse this with the Android application Gradle plugin ("com.android.application"). In that case, the targetSdk property remains essential and has not been deprecated.