【问题标题】:Flutter In App Purchase call does not return on AndroidFlutter In App Purchase 调用不会在 Android 上返回
【发布时间】:2021-12-09 15:00:51
【问题描述】:

(在 Android 上)在我的代码中,当我想开始获取产品 ID 时,代码永远不会超过这一行:

final bool isAvailable = await InAppPurchase.instance.isAvailable();

有时它会随机执行该行并在此处停止:

    try {
      ProductDetailsResponse productDetailResponse = await InAppPurchase.instance.queryProductDetails(_productIds.toSet());
      //...
    } on PlatformException catch (platformException) {
      print(platformException);
    } catch (error) {
      print(error);
    }

我将这两行都放入了 try-catch 错误中,但没有错误也没有异常。我现在一头雾水。

我正在使用in_app_purchase: ^2.0.0Flutter 2.5.3 stable channel

如果您有任何提示,我将不胜感激。

附注在 iOS 上一切正常

【问题讨论】:

  • @AwiasRehman 不是这样,它不执行该行,这就是问题所在。
  • 我最近遇到了一个类似问题的开发人员,这是由于在他们的 build.gradle 文件中包含 android 支付库引起的。
  • @developerextraordinare 你是什么意思?我把文档说的implementation "com.android.billingclient:billing-ktx:$billing_version"
  • Note: It is not necessary to depend on com.android.billingclient:billing in your own app's android/app/build.gradle file. If you choose to do so know that conflicts might occur. 取自pub.dev/packages/in_app_purchase

标签: flutter


【解决方案1】:

现在我有了答案: 删除flutter_inapp_purchase 包修复它!我想至少应该有一个警告!

【讨论】:

  • 谢谢!!!!!!
【解决方案2】:

我遇到了完全相同的问题。从应用程序级 build.gradle 中删除计费客户端实现解决了这个问题。详情请见this answer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-22
    • 1970-01-01
    • 1970-01-01
    • 2018-03-02
    • 2021-10-16
    • 2014-02-12
    • 1970-01-01
    相关资源
    最近更新 更多