Android 应用程序支持 android 11,即使编译和目标 SDK 版本设置为 28(android 9)

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

谁能解释一下 android 应用如何支持比该应用的 Compile 和 Target SDK 版本更高的 SDK 版本?

这是应用级别build.gradle

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

提前致谢!

来自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).

这意味着,如果应用安装在具有更高SDK的设备上,那么系统将尝试不启用兼容性功能,但应用仍然会运行。

否则,如果发布了新的 Android 版本,除非开发人员更新他们的应用程序,否则将无法使用该版本的应用程序。

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.

该应用程序将在 minSdkVersionmaxSdkVersion 之间的每个版本中被允许。