我正在android库中使用BLE。在该库的清单中,我使用<uses-permission ... />
标签指定了所需的权限:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
但是,从android-29(Q)开始,需要使用ACCESS_FINE_LOCATION
权限。
我可以简单地将其更新为ACCESS_FINE_LOCATION
,但是对于运行android-28及以下版本的设备,我要求“太多”。
是否有一种方法可以使我的清单包括不同的权限,具体取决于操作系统版本?
我认为可以通过设置样式和尺寸documentation来实现
productFlavors {
demo {
// Assigns this product flavor to the "mode" flavor dimension.
dimension "mode"
...
}
full {
dimension "mode"
...
}
// Configurations in the "api" product flavors override those in "mode"
// flavors and the defaultConfig block. Gradle determines the priority
// between flavor dimensions based on the order in which they appear next
// to the flavorDimensions property above--the first dimension has a higher
// priority than the second, and so on.
minApi24 {
dimension "api"
minSdkVersion 24
// To ensure the target device receives the version of the app with
// the highest compatible API level, assign version codes in increasing
// value with API level. To learn more about assigning version codes to
// support app updates and uploading to Google Play, read Multiple APK Support
versionCode 30000 + android.defaultConfig.versionCode
versionNameSuffix "-minApi24"
...
}
和清单合并documentation
希望有帮助。