BillingClient: In-app billing API version 3 is not supported on this device
Asked Answered
N

2

6

I'm developing an Android app and I am now at a point where I'm implementing in-app purchases. I have followed Android Developers' own guide to do this. However, when I launch my app, I get the following log in the console:

W/BillingClient: In-app billing API version 3 is not supported on this device.

I call the method setUpBillingClient() in my onCreate method in my MainActivity. The rest of the calls are like so:

private fun setUpBillingClient() {
        billingClient = BillingClient.newBuilder(this)
            .setListener(purchaseUpdateListener)
            .enablePendingPurchases()
            .build()
        startConnection()
    }

private val purchaseUpdateListener =  PurchasesUpdatedListener { billingResult, purchases ->

    }

private fun startConnection() {
    billingClient?.startConnection(object : BillingClientStateListener {
        override fun onBillingSetupFinished(billingResult: BillingResult) {
            if (billingResult.responseCode ==  BillingClient.BillingResponseCode.OK) {
                Log.v("TAG_INAPP","Setup Billing Done")
                // The BillingClient is ready. You can query purchases here.
                queryAvaliableProducts()
            }
        }
        override fun onBillingServiceDisconnected() {
            Log.v("TAG_INAPP","Billing client Disconnected")
            // Try to restart the connection on the next request to
            // Google Play by calling the startConnection() method.
        }
     })
   }

I am not getting any of the logs from the startConnection() method. I cannot seem to find anyone with a similar issue by Googling the issue. I have tried to use different emulators and different API's to see if it was the emulated device that was not compatible, but all of them gave the same error. Any suggestions?

I have also tried to implement the remaining code (complete purchaseUpdateListener and handlers for the purchases), but it still does not work. Something goes wrong at the beginning of the flow.

Noles answered 28/5, 2021 at 12:8 Comment(4)
What device do you use for testing? What Google Play Services version is installed?Redtop
For testing you must have real deviceTeddie
You need an emulator with PLay Store. An emulator with Play Store installed and a valid Google account can make test purchases. It is what I use mainly for debugging.Strongwilled
So it turns out that having an Emulator with Play Store was not enough for me (as I was already using that). However, it is working just fine when using my own Android device. Thanks for the help!Noles
S
18

This error message is extremely misleading. It just means that you first have to sign in to the Google Play Store on the device. I've filed this as a bug in the Google Play Billing Library issue tracker. https://issuetracker.google.com/issues/194746924

Note that not all Android emulators have Google Play Store support! If you don't have the Play Store on your emulator, you won't be able to login or test purchases.

When using the Android Studio AVD Manager, be sure to create a device that has Play Store support. In the examples you see here, the "Pixel 4" has Play Store support, but the "Pixel 4 XL" "Pixel 4a" and "Pixel XL" devices do not have the Play Store icon; those devices can't be used to test Play Billing.

The Android Studio AVD manager

Superfine answered 27/7, 2021 at 7:25 Comment(3)
If anyone facing this error in an actual device even though you have logged in, updated play store etc; check the accounts added in System settings. I had a defunct email address added in the list of all other emails. Once i removed it, it started working immediately.Synectics
Sadly, the error message is still the same in 2022. Thanks for your answer by the way!Griqua
Should I add login with a google account that has payment method enabled? Just having playservice isn't enough?Handmaid
C
2

The API is returning a weird error. In this case the error code is 3 and you get the following error message : Google Play In-app Billing API version is less than 3. The solution, is to link you Play Store application with one of your Google Account.

Add payment method. Final, app Billing working fine on emulator.

Consentient answered 27/8, 2021 at 1:39 Comment(1)
Should I add login with a google account that has payment method enabled? Just having playservice isn't enough?Handmaid

© 2022 - 2024 — McMap. All rights reserved.