You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android 13三星设备Google Play Integrity Error -2问题求助

三星Android 13设备Play Integrity报错-2的解决方案

问题背景

在三星Android 13设备上调用Google Play Integrity API检测设备安全状态时,触发以下非致命异常:

Non-fatal Exception: com.google.android.play.core.integrity.IntegrityServiceException
-2: Integrity API error (-2): The Play Store app is either not installed or not the official version. Ask the user to install an official and recent version of Play Store.

已确认用户安装官方Play Store,且正确配置Cloud项目编号:

val tokenRequest = IntegrityTokenRequest.builder()
            .setNonce(nonceEncoded)
            .setCloudProjectNumber(BuildConfig.GCP_PROJECT_NUMBER)
            .build()

当前使用Play Integrity版本为com.google.android.play:integrity:1.1.0。

解决方案

  • 升级Play Integrity库版本:1.1.0版本存在已知的Android 13兼容性问题,建议升级至最新稳定版(如1.2.0及以上),更新Gradle依赖:
    implementation 'com.google.android.play:integrity:1.2.0'
    
  • 强制更新Play Store:引导用户通过Play Store内的「我的应用和游戏」入口,将Play Store更新至最新版本——三星部分Android 13设备预装的旧版Play Store存在API适配缺陷。
  • 添加系统服务依赖声明:在AndroidManifest.xml中添加Google Play服务的依赖声明,确保系统能正确识别官方Play Store:
    <uses-library
        android:name="com.google.android.gms"
        android:required="true" />
    
  • 检查应用权限配置:确认应用已声明INTERNET权限,同时引导用户在三星设备的应用设置中开启「后台数据」权限——部分系统权限限制会阻断Play Integrity服务的网络请求。
  • 添加调用前预检查:发起IntegrityToken请求前,先验证Play Store服务可用性,提前拦截异常场景:
    val playServiceStatus = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context)
    if (playServiceStatus == ConnectionResult.SUCCESS) {
        // 执行IntegrityToken请求逻辑
    } else {
        // 提示用户修复Play Store服务
    }
    
  • 二次验证Cloud项目配置:确认Cloud项目已启用Play Integrity API,且应用的SHA-1指纹已正确添加至项目的API密钥配置中——配置遗漏会导致服务鉴权失败,触发类似报错。

内容的提问来源于stack exchange,提问作者avram andrei tiberiu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 20:22:07