Monday 9 November 2020

Google Play In-app Billing API version is less than 3 with updated Play Store

I'm using the Google Play Billing Library to offer some in-app purchases in my app. Everything is working correctly, but I'm receiving the error "Google Play In-app Billing API version is less than 3" on Crashlytics from some users, mainly using Samsung devices.

I've searched for similar issues and I found out that it can be caused either by having an outdated version of the Google Play Store installed or by not beign logged in with the Google account. The problem is that in many of the cases reported, the installed Play Store version is up-to-date and the account is correctly signed-in, because the first connection to the Billing Service is successfull.

For example, a user that had installed version 20.39.15 of Play Services and 22.4.29-21 of Play Store, had this kind of error flow:

  • Instantiate BillingClient
  • Call billingClient.startConnection
  • Received callback onBillingSetupFinished with response code OK
  • Query purchases and get successfull response

Then after a few seconds:

  • Received 3 calls to onBillingServiceDisconnected (this method does nothing in my implementation)
  • Received a call to onBillingSetupFinished with responseCode 3 and debugMessage: "Google Play In-app Billing API version is less than 3"

This is part of the code I'm using, I've omitted the logging for clarity:

class BillingManager(
    private val application: Application
) : PurchasesUpdatedListener, BillingClientStateListener {

...

    init {
        billingClient = BillingClient.newBuilder(application.applicationContext)
                .enablePendingPurchases()
                .setListener(this)
                .build()
        connectToPlayBillingService()
    }

    private fun connectToPlayBillingService() {
        if (!billingClient.isReady) {
            billingClient.startConnection(this)
        }
    }

    override fun onBillingSetupFinished(billingResult: BillingResult) {
        if (billingResult.responseCode == BillingResponseCode.OK) {
            queryPurchasesAsync()
        } else {
            handleBillingException(BillingException("Billing connection error", billingResult))
        }
    }

   override fun onBillingServiceDisconnected() {
        Log.w(TAG, "onBillingServiceDisconnected")
    }

...

}

Is this an issue with Samsung devices? Why do I receive multiple calls to onBillingSetupFinished when I call startConnection just once?



from Google Play In-app Billing API version is less than 3 with updated Play Store

No comments:

Post a Comment