android-inapp-billing-v3 icon indicating copy to clipboard operation
android-inapp-billing-v3 copied to clipboard

Error code 6 returning infinitely when initializing billing processor while signed out of google play.

Open DTRAIN opened this issue 8 years ago • 3 comments
trafficstars

Using version 10.0.40 when I initialize a new BillingProcessor object by calling:

bp = new BillingProcessor(this, LICENSE_KEY, MERCHANT_ID, new BillingProcessor.IBillingHandler() { .....

If I am signed out of google play on my device, the onBillingError callback is called infinitely from within the library returning error code 6 "Fatal API error". This infinitely repeating callback hangs my app and doesn't allow me to handle the error properly and tell the user to sign in to google play in order to load the store items.

Signing into google play fixes this issue and the store items load correctly.

DTRAIN avatar Sep 13 '17 20:09 DTRAIN

I've never experienced this myself, but then I've never tested with not being signed into Google. PRs welcome.

autonomousapps avatar May 20 '18 20:05 autonomousapps

I am experiencing the same thing on 10.0.44.

What happens

We have a StoreActivity that creates a new BillingProcessor via constructor e.g.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_store);
        // ...
        bp = new BillingProcessor(this, LICENSE_KEY, MERCHANT_ID, new BillingProcessor.IBillingHandler() {//...}

I stepped through the code and onBillingInitialized is triggered shorty after this constructor executes and the following code starts to run:

    public void handleBpResult() {
        if (bp.isInitialized()) {
            showView(mContent);

            // set up price text
            SkuDetails adFree = bp.getPurchaseListingDetails(Constants.SKU_PREMIUM);

As soon as bp.getPurchaseListingDetails(Constants.SKU_PREMIUM); is called the onBillingError callback is triggered and the infinite loop begins.

I checked and int errorCode for the callback is 6 and Throwable error is null. Case 6 in the switch for us is just a break which then starts the same handleBpResult function as above eventually running into bp.getPurchaseListingDetails(Constants.SKU_PREMIUM); and thus the cycle continues eventually crashing the app.

If I remove all billing processor related code from onBillingError then at least the infinite cycle is fixed but the errorCode 6 error will just appear later e.g. when the use attempts to purchase a store item.

Safety improvement

From a quick scan of the source getPurchaseListingDetails ends up calling getSkuDetails which interacts directly with the google inappbillingservice service. Thus calling anything that interacts with android billing like getPurchaseListingDetails inside the onBillingError could risk an infinite loop.

For our case the workaround is to use isPurchased which is a cache hit instead of interacting with the service and risking the loop. This is likely more efficient as well.

How to reproduce error code 6

Not sure. I have a device stuck in this state for any InAppBillingService related apps.

Blu Advance 5 Android 5.1

From settings>accounts I have a google account listed with sync off and when I click into the account for more details it says "Sync is currently experiencing problems. It will be back shortly"

Suggestions for improvement?

If possible getPurchaseListingDetails and getSubscriptionListingDetails could maybe be cache hits as well? From their function names it is not immediately obvious that they access billing service and they don't appear to be used internally to build the cache.

From a quick glance, there doesn't appear to be any public way to access purchase details from the cache even though the cache stores a map of ProductId->PurchaseInfo

oseparovic avatar Aug 25 '18 00:08 oseparovic

Any update on this? We still get spammed with error events 2 years on.

You can very easily reproduce an errorCode = 3 infinite loop by signing out of your google account and trying to visit your store page. onBillingError will be triggered over and over

oseparovic avatar Aug 21 '19 22:08 oseparovic