The Android SDK and API levels help your app work on different Android devices and versions.
Android SDK and API levels in Android Kotlin
android {
compileSdk = 33
defaultConfig {
minSdk = 21
targetSdk = 33
}
}compileSdk is the Android version your app is built against.
minSdk is the oldest Android version your app supports.
targetSdk is the Android version your app is tested for and optimized to run on.
android {
compileSdk = 33
defaultConfig {
minSdk = 21
targetSdk = 33
}
}android {
compileSdk = 30
defaultConfig {
minSdk = 16
targetSdk = 30
}
}android {
compileSdk = 33
defaultConfig {
minSdk = 33
targetSdk = 33
}
}This is a simple Android app setup in Kotlin that supports devices with Android 5.0 (API 21) and newer.
plugins {
id("com.android.application")
kotlin("android")
}
android {
compileSdk = 33
defaultConfig {
applicationId = "com.example.sdkapilevel"
minSdk = 21
targetSdk = 33
versionCode = 1
versionName = "1.0"
}
}
fun main() {
println("App supports Android API 21 and above.")
}Always test your app on devices or emulators with different API levels to catch compatibility issues.
Using a higher compileSdk lets you use new Android features but does not affect which devices can install your app.
Setting minSdk too high limits your app to fewer devices, but setting it too low may require extra work to support old versions.
The Android SDK and API levels control which Android versions your app supports and uses.
compileSdk is the version you build against, minSdk is the oldest supported version, and targetSdk is the version your app is optimized for.
Choosing the right API levels helps your app reach more users and use new features safely.