Google Play Integrity API prepareIntegrityToken调用无响应挂起问题排查
Google Play Integrity API prepareIntegrityToken挂起无响应问题排查
问题描述
调用Google Play Integrity API创建Standard Token时,prepareIntegrityToken会无征兆挂起,所有监听器(成功、失败、完成)均不触发。
相关代码
standardIntegrityManager = IntegrityManagerFactory.createStandard(context); standardIntegrityManager.prepareIntegrityToken( StandardIntegrityManager .PrepareIntegrityTokenRequest .builder() .setCloudProjectNumber(CLOUD_PROJECT_NUMBER) .build()) .addOnSuccessListener(response -> { // 业务代码 });
日志输出
StandardIntegrity : warmUpIntegrityToken(XXXXXXXXXXXX) StandardIntegrity : Already connected to the service. StandardIntegrity : Waiting to bind to the service
问题特征
- 无明确触发条件,正常运行一段时间后突然失效
- 重启手机后可能停止工作,重试无效
- 第三方工具Play Integrity API Checker(Nikolas Spiridakis开发)在同一设备上也会挂起,排除配额超限问题
- 已联系Google支持但未收到回复
可能的原因及排查步骤
1. Google Play服务进程异常或版本兼容问题
日志中的Waiting to bind to the service说明客户端无法正常绑定到Play服务的Integrity组件,大概率是Play服务进程僵死、崩溃,或版本与API不兼容:
- 检查设备上Google Play服务版本,升级到官方最新稳定版
- 手动清除Google Play服务的缓存和数据(路径:设置→应用→Google Play服务→存储→清除缓存/清除数据),重启设备后测试
2. 系统级服务绑定阻塞
安卓系统的Service绑定机制可能因系统资源耗尽、定制ROM限制或进程死锁出现异常,导致绑定请求一直处于等待状态:
- 在原生安卓设备上测试,排除定制ROM的影响
- 关闭后台无关应用,释放系统资源后重试
3. Integrity服务本地状态异常
设备本地的Play Integrity服务可能因之前的异常请求陷入卡住状态,而非服务端配额问题:
- 移除设备上的Google账号,重新添加后测试
- 重置Google Play服务框架(注意:此操作会清除Play服务相关数据,需谨慎执行)
4. 网络隐性干扰
部分网络环境(如代理、VPN、运营商深度包检测)可能影响Play服务与Google后端的通信,进而导致本地服务初始化异常:
- 切换网络环境(如从WiFi切换到移动数据)测试
- 关闭代理、VPN等网络工具后重新发起请求
额外排查点
- 尝试使用
IntegrityManagerFactory.createNonStandard创建非标准Token,观察是否同样挂起,缩小问题范围 - 通过
adb logcat查看设备系统日志,搜索更多与StandardIntegrity或bindService相关的异常信息,定位具体阻塞点
内容的提问来源于stack exchange,提问作者Jonas S.
相关产品推荐
相关产品推荐

