android Google Play完整性始终抛出错误代码-1 [未找到完整性Api]

nbnkbykc  于 2022-11-03  发布在  Android
关注(0)|答案(1)|浏览(230)

最近我添加了Google Play Integrity。我已经将Google服务json文件添加到项目中,启用了Google云控制台上的API,并更新了移动的上的Google Play商店,但我仍然得到错误代码-1 [Integrity Api not found]
我的代码是

val nonce: String = generateNonce() //generated nonce at my side

        // Create an instance of a manager.
        val integrityManager: IntegrityManager = IntegrityManagerFactory.create(context.applicationContext)

        // Request the integrity token by providing a nonce.
        val integrityTokenResponse: Task<IntegrityTokenResponse> = integrityManager.requestIntegrityToken(
                IntegrityTokenRequest.builder()
                        .setNonce(nonce)
                        .build())
        integrityTokenResponse.addOnSuccessListener { response ->
            val integrityToken: String = response.token()
            println("integrityToken:="+integrityToken)
        }
        integrityTokenResponse.addOnFailureListener { e ->
            println("integrityToken Error:="+e)
        }

任何帮助都将不胜感激。

rkkpypqq

rkkpypqq1#

我希望您已经解决了这个问题,但为了便于将来参考-如果您的应用正在运行,则必须在Google Play控制台中启用Play Integrity API。如果您的应用未在运行,则还应在请求中包含云项目编号:https://developer.android.com/reference/unity/class/Google/Play/Integrity/IntegrityTokenRequest#cloudprojectnumber。

相关问题