Android SDK 32 中的蓝牙有何变化?

问题描述 投票:0回答:3

将我的

targetSdk
更改为 32 后,出现以下错误:

Settings key: <bluetooth_address> is only readable to apps with targetSdkVersion lower than or equal to: 31

我认为这是在加载我的应用程序时检查权限时发生的。

android android-bluetooth
3个回答
4
投票

问题是由于少数参数被注释为 maxTargetSdk = Build.VERSION_CODES.S enter image description here

对于 bluetooth_name 我找到了替代方案并使用以下代码阅读 device_name

Settings.Global.getString(application.contentResolver, Settings.Global.DEVICE_NAME)
        ?: "UNKNOWN"

0
投票

我通过将 gradle 版本降级到 7.0.4 并将compileSdkVersion 和 targetSdkVersion 设置为 31 来解决这个问题。

不幸的是,这不是我想要的修复,但这是现在继续工作的中间步骤


0
投票

您无法直接更改目标版本。在此之前,请参阅有关将应用程序迁移到特定目标版本的 Android 文档。 如果不这样做将会导致错误,因为每个 Android SDK 都有自己的功能和升级,与旧代码不兼容。只需将 Target SDK 版本改回即可解决此错误。但是,最希望被弃用或很快被弃用。

© www.soinside.com 2019 - 2024. All rights reserved.