Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between compileSdk and compileSdkVersion in android studio gradle script when using jetpack compose

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"
}
like image 781
Vidyesh Churi Avatar asked Apr 25 '21 06:04

Vidyesh Churi


People also ask

What is compileSdkVersion in gradle?

compileSdkVersion defines which Android SDK version will be used by gradle to compile your app.

What is compileSdkVersion and targetSdkVersion in Android?

compileSdkVersion is the version of the compiler used in building the app, while targetSdkVersion is the "API level that the application targets".

What is the difference between minSdkVersion and targetSdkVersion?

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.

How do I check compileSdkVersion?

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.


1 Answers

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"
like image 145
Gabriele Mariotti Avatar answered Nov 08 '22 08:11

Gabriele Mariotti