从Flutter的Play商店获取产品时,应用内购买崩溃 [英] in-app purchase crashes when fetching products from the Play Store in Flutter

查看:130
本文介绍了从Flutter的Play商店获取产品时,应用内购买崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装并实施应用内购买插件 Flutter团队后,我遇到了问题.我到目前为止所做的:

  1. 在Play商店中添加了2个可见且有效的产品.
  2. 已提交构建版本以进行Alpha测试,因为这是应用程序内购买正常工作所必需的.
  3. 在应用启动时添加了 InAppPurchaseConnection.enablePendingPurchases();
  4. 向应用商店创建了一系列请求,最后一个请求失败,并显示了我无法解决的令人讨厌的日志

  bool available =等待_iap.isAvailable();如果可供使用的话) {print('=========>无法访问或访问存储.');} 别的 {设置< String>_kIds = {'农场','森林'};ProductDetailsResponse productResponse =等待_iap.queryProductDetails(_kIds);列表<产品详细信息>产品= productResponse.productDetails;}} 

  1. 此刻,每次 queryProductDetails 崩溃时,都会显示以下日志:

  E/AndroidRuntime(9053):java.lang.NoSuchMethodError:没有虚拟方法getIntroductoryPriceCycles()Ljava/lang/String;在Lcom/android/billingclient/api/SkuDetails类中;或其超级类("com.android.billingclient.api.SkuDetails"的声明出现在/data/app/com.my.fancy.app-6ImcBn8ELPgiO8hTXXp_3Q==/base.apk中)E/AndroidRuntime(9053):位于io.flutter.plugins.inapppurchase.Translator.fromSkuDetail(Translator.java:27)E/AndroidRuntime(9053):位于io.flutter.plugins.inapppurchase.Translator.fromSkuDetailsList(Translator.java:49)E/AndroidRuntime(9053):at io.flutter.plugins.inapppurchase.MethodCallHandlerImpl $ 1.onSkuDetailsResponse(MethodCallHandlerImpl.java:185)E/AndroidRuntime(9053):com.android.billingclient.api.zzj.run(com.android.billingclient:billing @@ 3.0.0:8)E/AndroidRuntime(9053):位于android.os.Handler.handleCallback(Handler.java:873)E/AndroidRuntime(9053):位于android.os.Handler.dispatchMessage(Handler.java:99)E/AndroidRuntime(9053):位于android.os.Looper.loop(Looper.java:193)E/AndroidRuntime(9053):位于android.app.ActivityThread.main(ActivityThread.java:6746)E/AndroidRuntime(9053):位于java.lang.reflect.Method.invoke(本机方法)E/AndroidRuntime(9053):在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:493)E/AndroidRuntime(9053):位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

我尝试在多个示例项目上运行它,但失败了.尝试过Kotlin和Java项目,只是想看看彼此之间是否有故障,但是没有运气.

编辑(已修复问题):该问题是由于build.gradle文件中链接的billingClient导致此问题而导致的.将其从gradle文件中删除后,一切都按预期开始工作.

解决方案

这花了一段时间,但以上内容似乎都不适合我.我发现,因为我也在使用RevenueCat,所以两个依赖项发生了冲突.到今天为止,将purchass_flutter替换为1.2.1而不是1.4.3为我解决了这个问题.

I am facing an issue after installing and implementing in-app purchase plugin Flutter team provided. What I did so far:

  1. added 2 products on Play Store that are visible and active.
  2. submitted build for alpha testing, since that is required for in-app purchase to work.
  3. added InAppPurchaseConnection.enablePendingPurchases(); at the app launch
  4. created a sequence of requests to the app store out of which last one fails with nasty log I can't work around

bool available = await _iap.isAvailable();
  if (!available) {
    print('=========> The store cannot be reached or accessed.');
  } else {
    Set<String> _kIds = {'farm', 'forest'};
    ProductDetailsResponse productsResponse = await _iap.queryProductDetails(_kIds);
    List<ProductDetails> products = productsResponse.productDetails;
  }      
}

  1. At the moment queryProductDetails crashes every single time with the following log:

E/AndroidRuntime( 9053): java.lang.NoSuchMethodError: No virtual method getIntroductoryPriceCycles()Ljava/lang/String; in class Lcom/android/billingclient/api/SkuDetails; or its super classes (declaration of 'com.android.billingclient.api.SkuDetails' appears in /data/app/com.my.fancy.app-6ImcBn8ELPgiO8hTXXp_3Q==/base.apk)
E/AndroidRuntime( 9053):    at io.flutter.plugins.inapppurchase.Translator.fromSkuDetail(Translator.java:27)
E/AndroidRuntime( 9053):    at io.flutter.plugins.inapppurchase.Translator.fromSkuDetailsList(Translator.java:49)
E/AndroidRuntime( 9053):    at io.flutter.plugins.inapppurchase.MethodCallHandlerImpl$1.onSkuDetailsResponse(MethodCallHandlerImpl.java:185)
E/AndroidRuntime( 9053):    at com.android.billingclient.api.zzj.run(com.android.billingclient:billing@@3.0.0:8)
E/AndroidRuntime( 9053):    at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime( 9053):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 9053):    at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime( 9053):    at android.app.ActivityThread.main(ActivityThread.java:6746)
E/AndroidRuntime( 9053):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9053):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime( 9053):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

I've tried running this on multiple example projects, and it fails. Tried with both Kotlin and Java project, just to see if there is something buggy with one or the other, but no luck.

EDIT (fixed the issue): Issue was result of a billingClient linked in build.gradle file that was causing this issue. Once I removed it from gradle file, everything started working as expected.

解决方案

This took a while, but none of the above seemed to work for me. I found out, as I'm also using RevenueCat that the two dependencies were clashing. As of today resolving purchases_flutter to 1.2.1 instead of 1.4.3 resolved this for me.

这篇关于从Flutter的Play商店获取产品时,应用内购买崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆