androidgoogle-play-servicesgoogle-play-integrity-api

Google Play integrity always throwing error code -1 [Integrity Api not found]


Recently I am adding Google play Integrity. I have added google service json file to the project , enabled API on google cloud console and updated Google Play Store on my mobile, but I am getting still the error code -1 [Integrity Api not found]

My Code is

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)
        }

Any help will be appreciate.


Solution

  • I hope you have resolved the issue already, but for future reference - Play Integrity API must be also enabled in Google Play Console if your app is on-Play. If your app is not on-Play - you should also include cloud project number in your request: https://developer.android.com/reference/unity/class/Google/Play/Integrity/IntegrityTokenRequest#cloudprojectnumber.