Android billing library V3.0.0 does not work

It does not work. As simple as that. I used default code given in google docs.

private fun initBilling() {
        val purchasesUpdatedListener = PurchasesUpdatedListener { billingResult, purchase ->
            Log.d("Billing", billingResult.debugMessage)
        }
        val billingClient = BillingClient.newBuilder(this@Home)
                .setListener(purchasesUpdatedListener)
                .enablePendingPurchases()
                .build()

        billingClient.startConnection(object : BillingClientStateListener {
            override fun onBillingSetupFinished(billingResult: BillingResult) {
                Log.d("Billing", billingResult.debugMessage
                        ?: "billing setup finished with response code ${billingResult.responseCode}")
                if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
                    // The BillingClient is ready. You can query purchases here.
                    CoroutineScope(Dispatchers.IO).launch {
                        querySkuDetails(billingClient)
                    }
                }
            }


            override fun onBillingServiceDisconnected() {
                // Try to restart the connection on the next request to
                // Google Play by calling the startConnection() method.
                Log.d("Billing", "disconnected")
            }
        })

   }

None of the Logs that I used were printed and no errors were showing. Start connection just does not trigger any methods from BillingClientStateListener.

Upvotes: 0

Views: 116

Answers (1)

There is an unknown issue with android billing library v3.0.0. Just switching to 2.1.0 helped.

Upvotes: 1

Related Questions