gpt4 book ai didi

android - 实现广告显示此错误 : Support for pending purchases must be enabled

转载 作者:行者123 更新时间:2023-11-29 22:40:08 26 4
gpt4 key购买 nike

根据文档,实现广告只是应用内消费品购买,当然不会被视为待定购买!(https://developer.android.com/google/play/billing/billing_rewarded_products + https://developer.android.com/google/play/billing/billing_onetime + https://developer.android.com/google/play/billing/billing_library_overview )。

但是我的应用程序在这一行崩溃了:

                billingClient = BillingClient.newBuilder(fragmentActivity)
.setChildDirected(BillingClient.ChildDirected.CHILD_DIRECTED)
.setUnderAgeOfConsent(BillingClient.UnderAgeOfConsent.UNDER_AGE_OF_CONSENT)
.setListener(that).build();

显示的错误是:

java.lang.IllegalArgumentException: Support for pending purchases must be enabled. Enable this by calling 'enablePendingPurchases()' on BillingClientBuilder.

所以根据我看的文档,这是自相矛盾的。即使是简单的广告,启用待定购买是否正常???

最佳答案

来自你在 stacktrace 中提到的错误

Enable this by calling 'enablePendingPurchases()'

我们可以找到方法 enablePendingPurchases() 的文档

This method is required to be called to acknowledge your application has been updated to support purchases that are pending. Pending purchases are not automatically enabled since your application will require updates to ensure entitlement is not granted before payment has been secured. For more information on how to handle pending transactions see https://developer.android.com/google/play/billing/billing_library_overview

If this method is not called, BillingClient instance creation fails

您的代码行应该是:-

    billingClient = BillingClient.newBuilder(fragmentActivity)
.setChildDirected(BillingClient.ChildDirected.CHILD_DIRECTED)
.enablePendingPurchases()
.setUnderAgeOfConsent(BillingClient.UnderAgeOfConsent.UNDER_AGE_OF_CONSENT)
.setListener(that).build();

May be you forgot to add this line .enablePendingPurchases()

希望对您有所帮助

关于android - 实现广告显示此错误 : Support for pending purchases must be enabled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59093210/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com