CompileSdkSpec

Added in 8.12.0-alpha06

interface CompileSdkSpec


Specifies the API level to compile your project against, which is required by the Android plugin.

This means your code can use only the Android APIs included in that API level and lower. You can configure the compile sdk version by adding the following block:

android {
compileSdk {
version = release(33) {
// this block and its properties are optional
minorApiLevel = 1
sdkExtension = 18
}
}
}

or to use a preview version:

android {
compileSdk {
version = preview("Tiramisu")
}
}

You should generally use the most up-to-date API level available.

If you are planning to also support older API levels, it's good practice to use the Lint tool to check if you are using APIs that are not available in earlier API levels.

This can be set on all Gradle projects with com.android.build.api.dsl.SettingsExtension.compileSdk

Summary

Public functions

CompileSdkVersion
addon(vendor: String, name: String, version: Int)

Specify an SDK add-on to compile your project against.

CompileSdkVersion
preview(codeName: String)

To set compile SDK version with a preview API level, use this function to compute the CompileSdkVersion and assign it to CompileSdkSpec.version property.

CompileSdkVersion
release(version: Int)

To set compile SDK version with a released API level, use this function to compute the CompileSdkVersion and assign it to CompileSdkSpec.version property.

CompileSdkVersion
release(version: Int, action: CompileSdkReleaseSpec.() -> Unit)

To set compile SDK version with a released API level, use this function to compute the CompileSdkVersion and assign it to CompileSdkSpec.version property.

Public properties

CompileSdkVersion?

The compile SDK version set for this project.

Public functions

addon

Added in 8.12.0-alpha06
fun addon(vendor: String, name: String, version: Int): CompileSdkVersion

Specify an SDK add-on to compile your project against.

This can be set on all Gradle projects with com.android.build.api.dsl.SettingsExtension.compileSdkAddon

Parameters
vendor: String

the vendor name of the add-on.

name: String

the name of the add-on

version: Int

the integer API level of the add-on

preview

Added in 8.12.0-alpha06
fun preview(codeName: String): CompileSdkVersion

To set compile SDK version with a preview API level, use this function to compute the CompileSdkVersion and assign it to CompileSdkSpec.version property.

release

Added in 8.12.0-alpha06
fun release(version: Int): CompileSdkVersion

To set compile SDK version with a released API level, use this function to compute the CompileSdkVersion and assign it to CompileSdkSpec.version property.

release

Added in 8.12.0-alpha06
fun release(version: Int, action: CompileSdkReleaseSpec.() -> Unit): CompileSdkVersion

To set compile SDK version with a released API level, use this function to compute the CompileSdkVersion and assign it to CompileSdkSpec.version property. When using a released API level, you can also set minor API level and SDK extension level via CompileSdkReleaseSpec block.

Public properties

version

Added in 8.12.0-alpha06
var versionCompileSdkVersion?

The compile SDK version set for this project.