android - 计费客户端 : In-app billing API version 3 is not supported on this device

标签 android in-app-billing android-billing

我正在开发一个 Android 应用程序,现在我正在实现应用程序内购买。我已经关注了Android开发者自己的guide去做这个。但是,当我启动我的应用程序时,我会在控制台中获得以下日志:W/BillingClient: In-app billing API version 3 is not supported on this device.我调用方法setUpBillingClient()在我的 MainActivity 中的 onCreate 方法中.其余的调用是这样的:

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.
        }
     })
   }
我没有从 startConnection() 获得任何日志方法。通过谷歌搜索问题,我似乎找不到任何有类似问题的人。我尝试使用不同的模拟器和不同的 API 来查看是否是不兼容的模拟设备,但它们都给出了相同的错误。有什么建议么?
我还尝试实现剩余的代码(完整的 purchaseUpdateListener 和购买处理程序),但它仍然不起作用。流程开始时出现问题。

最佳答案

此错误消息极具误导性。这只是意味着您首先必须在设备上登录 Google Play 商店。我已将此作为错误提交到 Google Play 结算库问题跟踪器中。 https://issuetracker.google.com/issues/194746924
请注意,并非所有 Android 模拟器都支持 Google Play 商店!如果您的模拟器上没有 Play 商店,您将无法登录或测试购买。
使用 Android Studio AVD 管理器时,请务必创建支持 Play 商店的设备。在您在这里看到的示例中,“Pixel 4”支持 Play Store,但“Pixel 4 XL”、“Pixel 4a”和“Pixel XL”设备没有 Play Store 图标;这些设备不能用于测试 Play Billing。
The Android Studio AVD manager

关于android - 计费客户端 : In-app billing API version 3 is not supported on this device,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67738549/

相关文章:

android - 警报对话框延迟弹出

android - 这是放置应用内购买成功通知的正确位置吗?

android - 为什么 android 构建系统不在库项目中包含 R.class,我该如何解决这个问题?

java - Android Studio-java.io.FileNotFoundException :(系统找不到指定的文件)并且无法提取JNI库

Android 应用内购买 : how to consume?

安卓工作室 : debug classes depending on a flavour

android - 使用 SOOMLA Android Store 计费包装器请求交易

android - onPurchasesUpdated 中的购买列表

android - 裁剪后设置 ImageView 不起作用

android - 对于下面提到的订阅服务、Stripe 或 Google 的应用内支付,我需要如何使用或使用哪种支付系统?