【问题标题】:Google play integrity api issue谷歌播放完整性 api 问题
【发布时间】:2022-06-17 15:30:16
【问题描述】:

我正在将我的应用程序从 Google Play 安全网 api 迁移到 Integrity api,但从 api 得到以下错误-

com.google.android.play.core.integrity.IntegrityServiceException:-12:完整性 API 错误 (-12):未知的内部 Google 服务器错误。 使用指数退避重试。如果持续失败,请考虑提交错误 (https://developer.android.com/reference/com/google/android/play/core/integrity/model/IntegrityErrorCode.html#GOOGLE_SERVER_UNAVAILABLE)。

以下是我的代码示例-

String str = "MTY1Mzk3NTAxMjYwNjE2NTM5NzUwMTI2MDc=";
byte[] strBytes = android.util.Base64.decode(str, android.util.Base64.DEFAULT);
byte[] encoded = android.util.Base64.encode(
            strBytes, android.util.Base64.URL_SAFE | android.util.Base64.NO_PADDING | android.util.Base64.NO_WRAP);
String nonce =  new String(encoded);
IntegrityManager integrityManager = 
                 IntegrityManagerFactory.create(getApplicationContext());
Task<IntegrityTokenResponse> integrityTokenResponse =
            integrityManager
                    .requestIntegrityToken(
                            IntegrityTokenRequest.builder().setNonce(nonce).build());

    integrityTokenResponse.addOnCompleteListener(new OnCompleteListener<IntegrityTokenResponse>() {
        @Override
        public void onComplete(@NonNull Task<IntegrityTokenResponse> task) {}
    });

    integrityTokenResponse.addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {}
    });

任何帮助将不胜感激。谢谢。

【问题讨论】:

    标签: android google-api


    【解决方案1】:

    我已经看到了这个问题,对我来说,解决方案是将 Cloud 项目编号包含在完整性请求中:

    IntegrityTokenRequest.builder()
                .setCloudProjectNumber([YOUR_CLOUD_PROJECT_NUMBER])
                .setNonce(nonce)
                .build()
    

    我构建了一个 SDK,因此这是唯一可用的解决方案,但是如果您有一个通过 Play 商店分发的应用程序,则有一个 alternative

    在 Play 管理中心,导航至左侧菜单的“发布”部分。转到设置 > 应用程序完整性。选择 Integrity API 选项卡即可开始使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-22
      • 2021-03-16
      • 2016-10-28
      • 1970-01-01
      • 2015-01-24
      • 1970-01-01
      • 2017-12-28
      • 2015-08-20
      相关资源
      最近更新 更多