Search code examples
androidsdkbuild.gradleandroid-sdk-tools

Android app is supporting android 11 even when compile and target SDK Versions are set to 28(android 9)


Can anyone explain how the android app supports the SDK versions that are higher than the Compile and Target SDK versions of that app?

Here is the app-level build.gradle

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

Thanks in advance!


Solution

  • From the official documentation:

    android:minSdkVersion:

    An integer designating the minimum API Level required for the application to run. The Android system will prevent the user from installing the application if the system's API Level is lower than the value specified in this attribute. You should always declare this attribute.

    android:targetSdkVersion

    An integer designating the API Level that the application targets. […] This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions (down to minSdkVersion).

    That means, if the app is installed in a device with a higher SDK, then the system will try not to enable compatibility features BUT the app will still run.

    Otherwise, if a new Android version was released, then no app would be available for it unless developers updated their apps.

    android:maxSdkVersion

    An integer designating the maximum API Level on which the application is designed to run. […]. In either case, if the application's maxSdkVersion attribute is lower than the API Level used by the system itself, then the system will not allow the application to be installed. In the case of re-validation after system update, this effectively removes your application from the device.

    The app will be allowed in EVERY version between minSdkVersion and maxSdkVersion.