简体   繁体   English

升级到 billingclient:billing:2.1.0 后,IabHelper 不再导入 android.vending.billing.IInAppBillingService

[英]IabHelper no longer imports android.vending.billing.IInAppBillingService after upgrading to billingclient:billing:2.1.0

On upgrading the billingclient to 2.1.0:将 billingclient 升级到 2.1.0:

implementation 'com.android.billingclient:billing:2.1.0'//from 2.0.1

I suddenly got a cannot resolve symbol 'vending' error in my IabHelper class:我突然在 IabHelper 类中遇到了无法解析符号“自动售货”错误:

在此处输入图片说明

I've had to go back to billing:2.0.1 to prevent this.我不得不回到 billing:2.0.1 来防止这种情况。 I notice the link to Trivial Drive 2 from the inapp billing docs https://github.com/android/play-billing-samples/tree/master/TrivialDrive_v2 now gives a '404' can't find error.我注意到来自 inapp 计费文档https://github.com/android/play-billing-samples/tree/master/TrivialDrive_v2 的Trivial Drive 2 链接现在给出了“404”找不到错误。 Digging through githup I see Trivail Drive 2 is archived, a new Kotlin example is now featured, 'TrivialDriveKotlin'.通过 Githup 挖掘,我看到 Trivail Drive 2 已存档,现在有一个新的 Kotlin 示例,“TrivialDriveKotlin”。

Is the Trivial Drive 2 implementation of inapp billing no longer supported by the latest billing code?最新的计费代码是否不再支持应用内计费的 Trivial Drive 2 实现? Is there an java version of the TrivialDriveKotlin code somewhere?某处是否有 Java 版本的 TrivialDriveKotlin 代码?

I could and will do a translation if there isn't, but there should be a java version of this up front.如果没有,我可以并且会进行翻译,但是应该预先有一个 Java 版本。 Getting the original trivial drive 2 code working and debugged in the first place was such a pain.首先让原始的普通驱动器 2 代码工作和调试是非常痛苦的。

My solution ended up being not to bother with the Trivial Drive example at all.我的解决方案最终是完全不打扰 Trivial Drive 示例。 The current implementation is simple enough to implement directly starting here https://developer.android.com/google/play/billing/billing_library_overview .当前的实现很简单,可以直接从这里开始实现https://developer.android.com/google/play/billing/billing_library_overview

The tricky part right from the start is this line:从一开始就棘手的部分是这一行:

billingClient = BillingClient.newBuilder(activity).setListener(this).build();

It's odd to see both 'activity' and 'this' used in the same line as you would typically substitute 'this' for 'activity'.看到在同一行中同时使用“活动”和“这个”很奇怪,因为您通常会将“这个”替换为“活动”。 You will get compile or runtime errors if these aren't set correctly.如果这些设置不正确,您将收到编译或运行时错误。 Better would be:更好的是:

billingClient = BillingClient.newBuilder(this).setListener(new PurchasesUpdatedListener() {...}).build();

or或者

PurchasesUpdatedListener puchaselistener;
puchaselistener = new PurchasesUpdatedListener() {...}
billingClient = BillingClient.newBuilder(this).setListener(purchaselistener).build();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM