1

I am trying to impliment android in app billing v3 and my application crashes with the following error Can't start async operation (consume) because another async operation(consume) is in progress

Stack trace is given below

02-25 16:56:54.811: E/AndroidRuntime(6913): FATAL EXCEPTION: main
02-25 16:56:54.811: E/AndroidRuntime(6913): java.lang.IllegalStateException: Can't start async operation (consume) because another async operation(consume) is in progress.
02-25 16:56:54.811: E/AndroidRuntime(6913):     at com.seven.BillingHelper.IabHelper.flagStartAsync(IabHelper.java:711)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at com.seven.BillingHelper.IabHelper.consumeAsyncInternal(IabHelper.java:832)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at com.seven.BillingHelper.IabHelper.consumeAsync(IabHelper.java:623)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at com.seven.javalib.InAppBilling$15.run(InAppBilling.java:350)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at android.os.Handler.handleCallback(Handler.java:587)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at android.os.Looper.loop(Looper.java:143)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at android.app.ActivityThread.main(ActivityThread.java:4196)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at java.lang.reflect.Method.invokeNative(Native Method)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at java.lang.reflect.Method.invoke(Method.java:507)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-25 16:56:54.811: E/AndroidRuntime(6913):     at dalvik.system.NativeStart.main(Native Method)

Can anyone please tell me how i can solve this

glo
  • 1,408
  • 3
  • 25
  • 54

3 Answers3

4

For a reason in a previous try the method flagEndAsync hasnot been called, make sure that in IabHelper in all cases (success or failure) the method flagEndAsync is called.

Nermeen
  • 15,883
  • 5
  • 59
  • 72
2

This can happen because IabHelper.handleActivityResult(requestCode, resultCode, data); is not called in the onActivityResult() method of your activity. You may want to verify that it is being called.

Tad
  • 4,668
  • 34
  • 35
1

Instead of updating all code. It's easier to make the flagEndSync method in your IabHelper public.

Then each time you make call to your IabHelper, call Mhelper.flagEndAsync() first. Then you know for sure you start with a clean Asynctask.

No crashes for me anymore.

Riverside
  • 207
  • 1
  • 12
  • 4
    What if there is really an async operation going on? If you call `flagEndAsync()` before each `flagStartAsync()`, there will be no point of using `mAsyncInProgress` flag. – Halil Oct 19 '14 at 18:04