libgdx / gdx-pay

A libGDX cross-platform API for InApp purchasing.
Apache License 2.0
225 stars 83 forks source link

v1.3.3 not working with google - PurchaseManagerGoogleBilling.onProductDetailsResponse failed, error code is -2 #250

Closed jim808 closed 1 year ago

jim808 commented 1 year ago

My IAPs were all working fine using gdx-pay v1.3.2. I updated my dependencies to 1.3.3, and gdx pay stopped being able to query google for offer details in the purchase manager.

I did not make any changes to my PurchageManagerConfig, but now, when I call purchaseManager.install(), the fetchOfferDetails() method receives a -2 error code from google., If I roll back to 1.3.2, this error goes away.

I can't find any migration docs from 1.3.2 to 1.3.3. What do I need to do differently in 1.3.3?

Here's the stack trace:

E/GdxPay/GoogleBilling: onProductDetailsResponse failed, error code is -2
I/ERROR: InAppPurchaseManager - PurchaseObserver.handleInstallError()
    com.badlogic.gdx.pay.FetchItemInformationException: Failed to fetch item list - check your connection (-2)
        at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling$3.onProductDetailsResponse(PurchaseManagerGoogleBilling.java:137)
        at com.android.billingclient.api.BillingClientImpl.queryProductDetailsAsync(com.android.billingclient:billing@@5.0.0:4)
        at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling.fetchOfferDetails(PurchaseManagerGoogleBilling.java:125)
        at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling.access$200(PurchaseManagerGoogleBilling.java:22)
        at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling$1.run(PurchaseManagerGoogleBilling.java:72)
        at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling$2.onBillingSetupFinished(PurchaseManagerGoogleBilling.java:88)
        at com.android.billingclient.api.zzap.zzd(com.android.billingclient:billing@@5.0.0:1)
        at com.android.billingclient.api.zzap.zza(com.android.billingclient:billing@@5.0.0:31)
        at com.android.billingclient.api.zzam.call(Unknown Source:2)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
MrStahlfelge commented 1 year ago

See #246

@keesvandieren everything fine to make a new release?

keesvandieren commented 1 year ago

Hi @MrStahlfelge / @jim808.

This is reported only by you. I checked the docs here: https://developer.android.com/reference/com/android/billingclient/api/BillingClient.BillingResponseCode#SERVICE_UNAVAILABLE

Docs:

The service is currently unavailable.

Since this state is transient, your app should automatically retry (e.g. with exponential back off) to recover from this error. Be mindful of how long you retry if the retry is happening during a user interaction.

This could potentially also be due to the user not having an active network connection.

Constant Value: 2 (0x00000002)

I believe we don't retry at all. Maybe we should implement retry in libgdx?

Is this always happening?

Does this also happen when you have a network connection?

What kind of products do you have? In-app products, subscriptions?

Are you sure the offer-type (product-type) is correct? I believe previous version of Google Play didn't specify the offer-type when querying product types (this wasn't needed if I remember correctly) now we are specifying the product-type. Maybe the product-type specified is not correct? E.g. on this line: https://github.com/libgdx/gdx-pay/blob/f01889cbfb17ae3163cf2d56ecf2709cf08fef6f/gdx-pay-android-googlebilling/src/com/badlogic/gdx/pay/android/googlebilling/PurchaseManagerGoogleBilling.java#L110-L110

jim808 commented 1 year ago

Hi,

I'm fairly certain that the underlying issue was that I was using a device emulator with an old version of the Play Store app installed. The code works just fine on devices with recent versions.

Thanks!

Jim

On Thu, Nov 10, 2022 at 10:12 AM Kees van Dieren @.***> wrote:

Hi @MrStahlfelge https://github.com/MrStahlfelge / @jim808 https://github.com/jim808.

This is reported only by you. I checked the docs here: https://developer.android.com/reference/com/android/billingclient/api/BillingClient.BillingResponseCode#SERVICE_UNAVAILABLE

Docs:

The service is currently unavailable.

Since this state is transient, your app should automatically retry (e.g. with exponential back off) to recover from this error. Be mindful of how long you retry if the retry is happening during a user interaction.

This could potentially also be due to the user not having an active network connection.

Constant Value: 2 (0x00000002)

I believe we don't retry at all. Maybe we should implement retry in libgdx?

Is this always happening?

Does this also happen when you have a network connection?

What kind of products do you have? In-app products, subscriptions?

Are you sure the offer-type (product-type) is correct? I believe previous version of Google Play didn't specify the offer-type when querying product types (this wasn't needed if I remember correctly) now we are specifying the product-type. Maybe the product-type specified is not correct? E.g. on this line: https://github.com/libgdx/gdx-pay/blob/f01889cbfb17ae3163cf2d56ecf2709cf08fef6f/gdx-pay-android-googlebilling/src/com/badlogic/gdx/pay/android/googlebilling/PurchaseManagerGoogleBilling.java#L110-L110

— Reply to this email directly, view it on GitHub https://github.com/libgdx/gdx-pay/issues/250#issuecomment-1310840513, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALIK4GYUXXRBH34VSTTND2LWHVJMFANCNFSM6AAAAAARUBXJHY . You are receiving this because you were mentioned.Message ID: @.***>