SufficientlySecure / donations

Donations library for Android. Supports Google Play Store, Flattr, PayPal, and Bitcoin
Apache License 2.0
347 stars 91 forks source link

IAB helper not set up exception #15

Closed aeroperf closed 9 years ago

aeroperf commented 9 years ago

Occasionally I get the following exception while using the library:

java.lang.IllegalStateException: IAB helper is not set up. Can't perform operation: launchPurchaseFlow at org.sufficientlysecure.donations.google.util.IabHelper.checkSetupDone(IabHelper.java:781) at org.sufficientlysecure.donations.google.util.IabHelper.launchPurchaseFlow(IabHelper.java:371) at org.sufficientlysecure.donations.DonationsFragment.donateGoogleOnClick(DonationsFragment.java:345) at org.sufficientlysecure.donations.DonationsFragment$1.onClick(DonationsFragment.java:218) at android.view.View.performClick(View.java:4439) at android.widget.Button.performClick(Button.java:148) at android.view.View$PerformClick.run(View.java:18395) at android.os.Handler.handleCallback(Handler.java:725) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5319) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) at dalvik.system.NativeStart.main(Native Method)

conzorz commented 9 years ago

Same here. Have found a solution: http://blog.android-develop.com/2014/10/android-l-api-21-javalangillegalargumen.html

aeroperf commented 9 years ago

That did the trick. Thanks for this @conzorz !

conzorz commented 9 years ago

No problem. You know whereabouts to apply it? I got confused reading it and just added "if version Lollipop, ignore" for now...

aeroperf commented 9 years ago

I added it in IabHelper.java, after line 267

Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent = createExplicitFromImplicitIntent(mContext, serviceIntent); if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) { ....

conzorz commented 9 years ago

Ah! It seems to just never work in emulator. Here's hoping...

Javinator9889 commented 6 years ago

I am getting this error again, and it happens in non-Lollipop devices. It is impossible for me to catch it and manage the exception. Here is the stack track trace: FATAL EXCEPTION: ControllerMessenger Process: javinator9889.bitcoinpools, PID: 8409 java.lang.IllegalStateException: IAB helper is not set up. Can't perform operation: launchPurchaseFlow at org.sufficientlysecure.donations.google.util.IabHelper.checkSetupDone(IabHelper.java:784) at org.sufficientlysecure.donations.google.util.IabHelper.launchPurchaseFlow(IabHelper.java:374) at org.sufficientlysecure.donations.DonationsFragment.donateGoogleOnClick(DonationsFragment.java:350) at org.sufficientlysecure.donations.DonationsFragment$1.onClick(DonationsFragment.java:226) at android.view.View.performClick(View.java:6256) at android.view.View$PerformClick.run(View.java:24697) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.support.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:148) at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:465) at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:421) at android.support.test.espresso.base.UiControllerImpl.injectMotionEvent(UiControllerImpl.java:235) at android.support.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:140) at android.support.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:123) at android.support.test.espresso.action.Tap.sendSingleTap(Tap.java:170) at android.support.test.espresso.action.Tap.access$100(Tap.java:31) at android.support.test.espresso.action.Tap$1.sendTap(Tap.java:47) at android.support.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:136) at android.support.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:355) at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:242) at android.support.test.espresso.ViewInteraction.access$100(ViewInteraction.java:62) at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:149) at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:146) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

dschuermann commented 6 years ago

@Javinator9889 Please open a new issue and make sure you use the latest version.