Android SDK version
The Build class allows you to get current version of Android.
// kotlin
import android.os.Build
...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
// ... do something for lollipop and above
} else{
// ... do something when an SDK is before lollipop
}
You can specify minimum SDK version and target SDK version in the module-level build.gradle file.
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
// ... other options
}
}
java support
Different versions of android does not support all features of Java 7/8. For example, try-with-resource feature need minSdkVersion is set to 19 or higher. Same thing with lambdas and stream API.
But android plugin for Gradle v4.0+ allows to use most features without changing minSdkVersion. Read more how add android gradle plugin on old projects.
You can specify java version in the module-level build.gradle file.
android {
// ...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
list of Android SDKs
API | SDK | name | description |
---|---|---|---|
30 | 11 | Android11 | Click to show/hide details |
29 | 10 | Android10 | |
28 | 9 | Pie | |
27 | 8.1.0 | Oreo | |
26 | 8.0.0 | Oreo | |
25 | 7.1 | Nougat | |
24 | 7.0 | Nougat | |
23 | 6.0 | Marshmallow | |
22 | 5.1 | Lollipop | Adds support for using more than one cellular carrier SIM card at a time. |
21 | 5.0 | Lollipop | Click to show/hide details |
19 | 4.4.x | KitKat | |
18 | 4.3.x | Jelly Bean | |
17 | 4.2.x | Jelly Bean | |
16 | 4.1.x | Jelly Bean | |
15 | 4.0.4 | Ice Cream Sandwich |