Applications may need to use APIs that are exclusive to specific versions of Android. Checking the version of Android that an app is currently running on allows the developer to cause different actions to occur, depending on which operating system is installed on the device.
This can be done by setting the compileSdkVersion, minSdkVersion, and targetSdkVersion in the build.gradle file of an Android project, then determining which APIs should be used by checking the Android version at runtime.
Understanding the SDK version settings
compileSdkVersion— The Android API level your app is compiled against. This determines which APIs are available to you at compile time.minSdkVersion— The lowest Android API level your app supports. Devices running a version below this will not be able to install your app.targetSdkVersion— The API level your app is designed and tested against. This affects how the system applies behavior changes and compatibility modes.
When submitting to the Amazon Appstore, these values in your app manifest and build.gradle file determine which Fire devices your app can be installed on. See the Device Filtering and Compatibility docs for full details on how these values affect device support.
Fire OS and Android API level mapping
Fire OS is based on Android, and each Fire OS version corresponds to a specific Android API level:
| Fire OS version | Android version | API level |
|---|---|---|
| Fire OS 5 | Android 5.1 (Lollipop) | 22 |
| Fire OS 6 | Android 7.1 (Nougat) | 25 |
| Fire OS 7 | Android 9 (Pie) | 28 |
| Fire OS 8 | Android 11 | 30 |
Example code
Here are example code snippets showing how to configure your build and check the Android version at runtime.
build.gradle file:
android {
compileSdkVersion 33
defaultConfig {
minSdkVersion 25
targetSdkVersion 33
}
}
In Java and Kotlin:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// Code targeting Fire OS 7 (Pie, API 28) or later
}
else {
// Code targeting Fire OS 6 (Nougat, API 25) or earlier
}
You can use more granular checks to target specific Fire OS versions:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// Code targeting Fire OS 8 (Android 11, API 30) or later
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// Code targeting Fire OS 7 (Pie, API 28)
} else {
// Code targeting Fire OS 6 (Nougat, API 25) or earlier
}
Related:
Last updated: Mar 11, 2026