How to correctly import BillingResponse with newest version of billing client (billing:2.0.1)
Asked Answered
P

2

9

I'm upgrading my version of android billing api from 1.2.2 to 2.0.1. But now my import of the '''BillingResponse''' api is returning an error. How can I properly import BillingResponse with version 2.0.1?

I'm working with gradle inside of Android Studio.

I've tried: - Cleaning and rebuilding my project - Closing the application and reopening - Restarting my machine - File > Sync project with gradle files

None of those worked so far with 2.0.1, but when I go back to 1.2.2 version of the android billing API it works again! I could not find any documentation that BillingResponse had been deprecated so I was expecting it to work even with an updated api


My relevant gradle dependencies:

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation project(':libcocos2dx')
  implementation 'com.google.android.gms:play-services-games:17.0.0'
  implementation 'com.google.android.gms:play-services-auth:16.0.1'
  implementation 'com.android.billingclient:billing:2.0.1'

My import statements inside of BillingProvider.java which implements PurchasesUpdatedListener:

import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.BillingClient.BillingResponse;
import com.android.billingclient.api.BillingClient.FeatureType;
import com.android.billingclient.api.BillingClient.SkuType;

^ note that all of the other imports are working here except the .BillingResponse one!

I expected the BillingResponse to still be available in 2.0.1 but it can't seem to find it now that I have upgraded...

Pirozzo answered 3/7, 2019 at 19:26 Comment(2)
what is the error message?Necessaries
it was "Cannot resolve symbol BillingResult"Pirozzo
C
2

Check https://developer.android.com/google/play/billing/billing_library_releases_notes

BillingResult return values

APIs that previously returned a BillingResponse integer value now return a BillingResult object. BillingResult contains the BillingResponse integer as well as a debug string that you can use to diagnose errors. The debug string uses an en-US locale and is not meant to be shown to end users.

Chunk answered 3/7, 2019 at 19:32 Comment(1)
Awesome thanks. I also found I can check against codes just using BillingResponseCode instead of BilliingResponse developer.android.com/reference/com/android/billingclient/api/…Pirozzo
A
0

instead of importing import com.android.billingclient.api.BillingClient.BillingResponse; I used BillingClient.BillingResponseCode.OK object instead and it worked

Adalbertoadalheid answered 30/11, 2019 at 6:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.