Use version targeting to support Android APIs

:information_source: Make sure to read the appstore docs on device filtering and compatibility here: Device Filtering and Compatibility | App Submission

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.

Here are some example code snippets:

build.gradle file:

android {
  compileSdkVersion 25
  defaultConfig {
    minSdkVersion 21
    targetSdkVersion 25
   }
}

In Java and Kotlin:

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.NOUGAT) {
      // Code targeting FIRE OS 6 (NOUGAT) or later versions
   }
  else {
      // Code targeting FIRE OS 5 (LOLLIPOP)
  } 

Related: