I tried to include in-app billing in my app and for the purpose of testing, based the whole procedure on the \"TrivialDrive\" example for version 3 of in-app billing (and im
If you have lucky patcher installed and the modded playstore you will get the message " iab helper is not set up " . Solution : install an android emulator on your PC or lucky patcher and the modded playstore will not be installed.You will no longer have the error message and will be able to make your payment, it worked perfect for me :)
Had the same issue while executing purchaseFlow function. Take a look at Activity class in the Google's example and specifically at the method protected void onActivityResult(int requestCode, int resultCode, Intent data)
. You probably forgot to implement this one. This function is vital for the whole mechanism to work without a glitch.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
// Pass on the activity result to the helper for handling
if (!inappBillingHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
else {
Log.i(TAG, "onActivityResult handled by IABUtil.");
}
}
EDIT: Additionally the problem also exists when you have wrong password associated with your gmail account on your phone (this happened on me today). Of course all the Inapp billing features should be tested on the phone, but that I think is obvious.
The fundamental problem is that startRegistered() is being invoked in direct response to a UI user click, whereas the setup of your IabHelper object is triggered asynchronously, and so cannot be known to have completed until an asynchronous response is received via onIabSetupFinished().
Your startRegistered() method is triggered by a user click, and that calls launchPurchaseFlow(), which in turn requires that the IabHelper object has already completed setup, but if the user clicks to trigger a purchase before that confirmation is received (either because setup failed or because the user is exceptionally quick on the draw), then setup will not have been completed, and launchPurchaseFlow() will report the error that you're seeing. In the case of your logcat, the delay is 14 seconds, which would usually be enough time, but...maybe not in this case. Or, maybe something went wrong and you never would have connected no matter how long you had waited.
In your logcat, there's no message indicating "Billing service connected," which is one of the first things that must happen if your setup is to complete. Since that does not occur, you are also not seeing any message (either of success or of failure) from onIabSetupFinished().
This is tricky stuff because of the asynchronous responses required. One approach would be to disable the button used to trigger a purchase until your onIabSetupFinished() returns with success. This would prevent the triggering of the purchase until the IabHelper object had been successfully set up. Of course, if setup fails, you'll have a non-functioning button, but at least you can tell the user what's up (by putting up a message that indicates you're waiting for setup to complete - e.g., as part of the button text).
Even then, once your purchase is initiated and the payment dialog appears to the user, there's the possibility of your app going through an onStop() cycle that flushes your app from memory while the user is pondering her purchase (since the purchase dialog is part of Google Play, not part of your app, and the OS may require memory to run it, and that memory may be obtained by stopping your app). That would destroy your IabHelper() object, which would then have to be created and asynchronously set up again. And again, since that is be triggered asynchronously in your onCreate() method, onActivityResult() may be invoked by the Google Play service to report the user's purchase action before the IabHelper object's setup has completed, and since in onActivityResult() you will need to use your IabHelper instance, this could result in an error. It seems that you have to be prepared for anything.
This should give you the flavor of what you're dealing with. IAB is difficult for exactly these reasons - multiple threads of asynchronous stuff (e.g., setup vs. purchases vs. Android OS actions that stop your app to grab memory for use by, quite possibly, the very Google Play app purchase operation for which your app is waiting to obtain the results of the purchase). A lot of what gets implemented (including by the TrivialDrive sample) is flaky because it implicitly relies upon your app staying in memory when in fact it might get recycled, or because it relies upon one leg of a race condition (e.g. setup) completing before another leg (e.g., purchase launch) does, and so on.
I have just finished wrapping my head around the exact same problem. IabHelper-Setup starts, but after that, nothing else happens. And clicking on an in-App-Purchase returns the exact same error you had.
Here's what I figured out: I only used emulators from eclipse. Once I read that a certain Google Play version is required, I noticed that Google Play was missing entirely on my test emulation drives.
When I then used a real phone it worked flawlessly! So if you happen to be still stuck on that problem, try to use a real device (if you have one available). That should do the trick.
Another thing that I came across; while you might have the latest version of google play on your device which supports the latest version of in app billing, other users may not. And while crashes caused by this in theory should appear in the developer console, I could not see these crashes until I implemented firebase...and then I saw a lot of them. What I ended up doing was using a try catch and linking users who didn't have the latest version of google play or experienced a problem on the google play store end to this page https://support.google.com/googleplay/answer/1050566?hl=en
try {
mHelper.launchPurchaseFlow(this, SKU_PRO_LT, RC_REQUEST,
mPurchaseFinishedListener, payload);
} catch (Exception e) { //with IabHelper.IabAsyncInProgressException the code still fatally crashes for some reason
//complain("Error launching purchase flow. Another async operation in progress.");
alert2("[error msg]");
setWaitScreen(false);
}
alert2 is just a dialog box with a link to the webpage above.
But firstly I'd recommend testing out in app purchases on a few friends phones just to make sure it's a play store update issue and not a code issue.