23

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"
}
Vidyesh Churi
  • 1,899
  • 1
  • 24
  • 33

1 Answers1

37

With the new Android Gradle Plugin 7.0.0 (currently 7.0.0-alpha14) you can use:

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:

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"
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • compileSdkPreview = "S" not supported instead compileSdkPreview = "android-S" i.e. string value need to be android-S – Vidyesh Churi Apr 25 '21 at 08:41
  • @VidyeshChuri I've added the related links for all these attributes. About the implementation of the preview String I'am not sure. May be it will change with 1.0.0-beta01: check this commit: https://cs.android.com/android-studio/platform/tools/base/+/5bce01033e4c217c29c55c19631a4d8223fc2a3c:build-system/gradle-api/src/main/java/com/android/build/api/dsl/CommonExtension.kt;dlc=671867896f7879aa91dbf1f43b48a1570e677df6 – Gabriele Mariotti Apr 25 '21 at 08:49
  • Do I need to add **compileSdk** along with **compileSdkPreview** to build bundle / release app on playstore? – Vidyesh Churi Apr 25 '21 at 08:50
  • 1
    @VidyeshChuri In any case you can still use the *old* `compileSdkVersion`. If you are using `compileSdkPreview` it overrides the `compileSdk` value. Are you using 7.0.0-alpha14 ? – Gabriele Mariotti Apr 25 '21 at 08:56
  • @GabrieleMariotti is SDK 12 already supported because no matter what I did its either a failed Gradle sync or cannot install the app after changing its compile and target to this new SDK. Here is my question as well. https://stackoverflow.com/q/67649546/12204620 – Bitwise DEVS May 22 '21 at 13:41