java.lang.SecurityException: getImeiForSlot: The user 10282 does not meet the requirement

这两天项目升级Android 编译版本,将build.gradle 中的 compileSdkVersion 升级到 29后,发现APP在Android 10 及Android 11设备上在调用获取设备信息的时候崩溃了。

问题描述:
Android 编译版本升级为29后,在Android 10 和Android 11 手机上获取设备信息崩溃,报错
java.lang.SecurityException: getImeiForSlot: The user 10282 does not meet the requirements to access device identifiers.

解决方案:

1、降低targetSdkVersion版本

我们可以将支持版本降低到 29 一下,也就是 targetSdkVersion=28 这样就可以解决问题了。但是这种做法不建议,毕竟后面还是要升级到新版本的。

参考:https://blog.csdn.net/u013132758/article/details/111326319

原文地址:https://www.cnblogs.com/changyiqiang/p/14537290.html