# CompileSdkSpec

# CompileSdkSpec

[View Source](https://cs.android.com/search?q=file:com/android/build/api/dsl/CompileSdkSpec.kt+class:com.android.build.api.dsl.CompileSdkSpec)  
Added in 8.13.0-alpha02  

<br />

```
interface CompileSdkSpec
```

<br />

*** ** * ** ***

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:  

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

or to use a preview version:  

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

You should generally[use the most up-to-date API level](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)available.

If you are planning to also support older API levels, it's good practice to[use the Lint tool](https://developer.android.com/studio/write/lint.html)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](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/SettingsExtension#compileSdk())

## Summary

|                                                      ### Public functions                                                      |
|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [CompileSdkVersion](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion) | [addon](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#addon(kotlin.String,kotlin.String,kotlin.Int))`(vendor: `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, name: `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, version: `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Specify an SDK add-on to compile your project against.                                                                                                                                                                                                                                                                                                                                                                              |
| [CompileSdkVersion](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion) | [preview](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#preview(kotlin.String))`(codeName: `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` To set compile SDK version with a preview API level, use this function to compute the[CompileSdkVersion](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion)and assign it to[CompileSdkSpec.version](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#version())property.                                                                                                                                                                                                                                                  |
| [CompileSdkVersion](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion) | [release](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#release(kotlin.Int))`(version: `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` To set compile SDK version with a released API level, use this function to compute the[CompileSdkVersion](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion)and assign it to[CompileSdkSpec.version](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#version())property.                                                                                                                                                                                                                                                           |
| [CompileSdkVersion](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion) | [release](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#release(kotlin.Int,kotlin.Function1))`(version: `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, action: `[CompileSdkReleaseSpec](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkReleaseSpec)`.() `->` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)` To set compile SDK version with a released API level, use this function to compute the[CompileSdkVersion](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion)and assign it to[CompileSdkSpec.version](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#version())property. |

|                                                       ### Public properties                                                       |
|-----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [CompileSdkVersion](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion)`?` | [version](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#version()) The compile SDK version set for this project. |

## Public functions

### addon

Added in 8.13.0-alpha02  

```
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](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/SettingsExtension#compileSdkAddon(kotlin.String,kotlin.String,kotlin.Int))  

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|-------------------------------------|
| `vendor: `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | the vendor name of the add-on.      |
| `name: `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)   | the name of the add-on              |
| `version: `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)      | the integer API level of the add-on |

### preview

Added in 8.13.0-alpha02  

```
fun preview(codeName: String): CompileSdkVersion
```

To set compile SDK version with a preview API level, use this function to compute the[CompileSdkVersion](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion)and assign it to[CompileSdkSpec.version](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#version())property.  

### release

Added in 8.13.0-alpha02  

```
fun release(version: Int): CompileSdkVersion
```

To set compile SDK version with a released API level, use this function to compute the[CompileSdkVersion](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion)and assign it to[CompileSdkSpec.version](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#version())property.  

### release

Added in 8.13.0-alpha02  

```
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](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkVersion)and assign it to[CompileSdkSpec.version](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkSpec#version())property. When using a released API level, you can also set minor API level and SDK extension level via[CompileSdkReleaseSpec](https://developer.android.com/reference/tools/gradle-api/8.13/com/android/build/api/dsl/CompileSdkReleaseSpec)block.  

## Public properties

### version

Added in 8.13.0-alpha02  

```
var version: CompileSdkVersion?
```

The compile SDK version set for this project.