Leia@Amazon avatar image
Leia@Amazon posted

Using Android Version Targeting to Support Multiple Operating Systems

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 Studio project, then determining which APIs should be used by checking the Android version at runtime.

Sample Code:

// build.gradle file

android {
	compileSdkVersion 25
	defaultConfig {
		minSdkVersion 21
		targetSdkVersion 25


// java file

public void checkAndroidVersion() {
	 // Code targeting FIRE OS 6 (NOUGAT)

	else {
	// Code targeting FIRE OS 5 (LOLLIPOP)
app submission and updatesandroid
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.



Brian@Amazon contributed to this article leia contributed to this article