首页 > 解决方案 > Google Play In-app Billing API 版本低于 3 并更新了 Play Store

问题描述

我正在使用 Google Play 结算库在我的应用中提供一些应用内购买。一切正常,但我在 Crashlytics 上收到一些用户(主要使用三星设备)的错误“Google Play In-app Billing API version is less than 3”。

我搜索了类似的问题,发现这可能是由于安装了过时的 Google Play 商店版本或未使用 Google 帐户登录造成的。问题在于,在报告的许多情况下,安装的 Play 商店版本是最新的,并且帐户已正确登录,因为与计费服务的第一次连接是成功的。

例如,安装20.39.15了 Play Services 和22.4.29-21Play Store 版本的用户,会出现这种错误流:

然后几秒钟后:

这是我正在使用的代码的一部分,为了清楚起见,我省略了日志记录:

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

...

}

这是三星设备的问题吗?为什么onBillingSetupFinishedstartConnection只打一次就接到多个电话?

标签: androidgoogle-play-servicesplay-billing-library

解决方案


推荐阅读