When I created new android project with jetpack compose toolkit with or without kotlin dsl I found that in module level build.gradle file the property compileSdkVersion has been replaced by compileSdk. I also found that android sdk version "android-S" couldn't be added to compileSdk for that compileSdkVersion = "android-S" needed to be added seperately. My question is what exactly is difference between compileSdk and compileSdkVersion.
build.gradle.kts(Module:Compose.app)
android {
compileSdk = 30
buildToolsVersion = "30.0.3"
compileSdkVersion = "android-S"
}
compileSdkVersion defines which Android SDK version will be used by gradle to compile your app.
compileSdkVersion is the version of the compiler used in building the app, while targetSdkVersion is the "API level that the application targets".
The min sdk version is the earliest release of the Android SDK that your application can run on. Usually this is because of a problem with the earlier APIs, lacking functionality, or some other behavioural issue. The target sdk version is the version your application was targeted to run on.
If you are confused on which version number to use, go to Android SDK Manager , locate the API level you are using (Which must always be the latest) and there you will find the version to use (Android 7 (API 24) as at time of writing). Show activity on this post.
With the new Android Gradle Plugin 7.0.0
(currently 7.0.0-alpha14
) you can use:
minSdk
instead of minSdkVersion
targetSdk
instead of targetSdkVersion
compileSdk
instead of compileSdkVersion
These attributes work with an Int
and you can use them with something like:
//minSdkVersion 21
//targetSdkVersion 30
minSdk 21
targetSdk 30
If you want to use a preview version you have to use:
minSdkPreview
targetSdkPreview
compileSdkPreview
These attributes work with a String
and setting these values will override previous values of minSdk
/targetSdk
/compileSdk
.
About the String format of the preview versions currently (7.0.0-alpha14
) it is not clear. Maybe it will change with 7.0.0-beta01
(you can check this commit) and it should be:
compileSdkPreview = "S"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With