android - 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-21
Play Store 版本的用户,会出现这种错误流:
- 实例化
BillingClient
- 称呼
billingClient.startConnection
- 收到
onBillingSetupFinished
带有响应代码的回调OK
- 查询购买并获得成功响应
然后几秒钟后:
- 收到3 次调用(此方法在我的实现中
onBillingServiceDisconnected
没有任何作用) - 接到电话3 并且
onBillingSetupFinished
:“Google Play In-app Billing API version is less than 3”responseCode
debugMessage
这是我正在使用的代码的一部分,为了清楚起见,我省略了日志记录:
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")
}
...
}
这是三星设备的问题吗?为什么onBillingSetupFinished
我startConnection
只打一次就接到多个电话?
解决方案
推荐阅读
- reactive-programming - Spring WebFlux - 如何从数据库中获取值并设置此值以创建对象
- reactjs - React useEffect 跟踪依赖数组最佳实践中可用的所有值
- vue.js - pouchdb live 对于实时聊天来说有点太快了
- python - 在 Flask-Restful 中使用蓝图有什么好处?
- c# - 我们如何在 c# 中通过条目 ID 将行转换为列
- mysql - MYSQL 使用索引不起作用但强制索引有效?
- cadence-workflow - Cadence 或 Temporal 中的自定义工作流程
- c# - 如何在 ASP.NET 的选择框中将我的模型字段设置为选定的值?
- kubernetes - 使用 Ansible 在 Pod 达到一定年龄时删除 DeploymentConfig
- c++ - 如何将带有参数包的模板类作为参数传递给其他模板类?