Android 取决于 SDK 版本的清单属性

Android Manifest attributes depending on SDK version

Android 11 引入了各种隐私更改,包括 scoped storage。这意味着在 Android 11 或更高版本上,应用不再

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

但我仍然需要在 Android 10 或更低版本上维护该功能。是否可以根据SDK版本声明Manifest权限和属性?

here

<uses-permission android:name="string"
    android:maxSdkVersion="integer" />

android:maxSdkVersion

The highest API level at which this permission should be granted to your app. Setting this attribute is useful if the permission your app requires is no longer needed beginning at a certain API level. For example, beginning with Android 4.4 (API level 19), it's no longer necessary for your app to request the WRITE_EXTERNAL_STORAGE permission when your app wants to write to its own application-specific directories on external storage (the directories provided by getExternalFilesDir()). However, the permission is required for API level 18 and lower. So you can declare that this permission is needed only up to API level 18 with a declaration such as this:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
     android:maxSdkVersion="18" />

因此您的 maxSdkVersion 将是 28(因为 Android 10/ API 29 级或更高级别的应用不需要请求它)。你的问题提到 Android 11 但阅读文档似乎允许 Android 10 及以上。