I applied the app to purchase in my app. I used the “TrivialDrive” example for version 3 of the billing in the application, I tested the application with static answers, everything works as expected.
But when I download the application from the market, upon successful purchase the application crashes,
My successful purchase code
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() { public void onIabPurchaseFinished(IabResult result, Purchase purchase) { Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase); if (result.isFailure()) { complain("Error purchasing: " + result); } if (purchase != null) { if (purchase.getSku().equals(Constants.IN_APP_PURCHASE_PRODUCT_ID)) {
I have a successful purchase message, but I do not see this message (this means that linux is not running it) when I successfully purchased it, after the application crashes, the application crashes.
When you restart the application and try to buy a product, it is already purchased.
I received a crash message from the developer console.
02-09 02:01:13.181: E/AndroidRuntime(11530): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=10001, result=-1, data=Intent { (has extras) }} to activity {com.eknathkadam.grammaruplite/com.webrich.base.ui.GoogleInAppPurchaseActivity}: java.lang.NullPointerException 02-09 02:01:13.181: E/AndroidRuntime(11530): at android.app.ActivityThread.deliverResults(ActivityThread.java:3141) 02-09 02:01:13.181: E/AndroidRuntime(11530): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3184) 02-09 02:01:13.181: E/AndroidRuntime(11530): at android.app.ActivityThread.access$1100(ActivityThread.java:130) 02-09 02:01:13.181: E/AndroidRuntime(11530): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243) 02-09 02:01:13.181: E/AndroidRuntime(11530): at android.os.Handler.dispatchMessage(Handler.java:99) 02-09 02:01:13.181: E/AndroidRuntime(11530): at android.os.Looper.loop(Looper.java:137) 02-09 02:01:13.181: E/AndroidRuntime(11530): at android.app.ActivityThread.main(ActivityThread.java:4745) 02-09 02:01:13.181: E/AndroidRuntime(11530): at java.lang.reflect.Method.invokeNative(Native Method) 02-09 02:01:13.181: E/AndroidRuntime(11530): at java.lang.reflect.Method.invoke(Method.java:511) 02-09 02:01:13.181: E/AndroidRuntime(11530): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 02-09 02:01:13.181: E/AndroidRuntime(11530): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-09 02:01:13.181: E/AndroidRuntime(11530): at dalvik.system.NativeStart.main(Native Method) **02-09 02:01:13.181: E/AndroidRuntime(11530): Caused by: java.lang.NullPointerException 02-09 02:01:13.181: E/AndroidRuntime(11530): at com.google.billing.Base64.decode(Base64.java:434)** 02-09 02:01:13.181: E/AndroidRuntime(11530): at com.google.billing.Security.generatePublicKey(Security.java:87) 02-09 02:01:13.181: E/AndroidRuntime(11530): at com.google.billing.Security.verifyPurchase(Security.java:66) 02-09 02:01:13.181: E/AndroidRuntime(11530): at com.google.billing.IabHelper.handleActivityResult(IabHelper.java:437) 02-09 02:01:13.181: E/AndroidRuntime(11530): at com.webrich.base.ui.GoogleInAppPurchaseActivity.onActivityResult(GoogleInAppPurchaseActivity.java:238) 02-09 02:01:13.181: E/AndroidRuntime(11530): at android.app.Activity.dispatchActivityResult(Activity.java:5192) 02-09 02:01:13.181: E/AndroidRuntime(11530): at android.app.ActivityThread.deliverResults(ActivityThread.java:3137) 02-09 02:01:13.181: E/AndroidRuntime(11530): ... 11 more 02-09 02:02:20.610: E/JavaBinder(250): !!! FAILED BINDER TRANSACTION !!! 02-09 02:02:20.638: E/MountService(250): Listener dead 02-09 02:02:20.638: E/MountService(250): Listener dead 02-09 02:02:22.028: E/InputDispatcher(250): channel '41f313f0 com.android.vending/com.android.vending.AssetBrowserActivity (server)' ~ Channel is unrecoverably broken and will be disposed! 02-09 02:03:59.884: E/PowerManagerService(250): Excessive delay setting brightness: 198ms, mask=2
Its throwing Null Pointer exceptions in the onActivityResult () method on this line
if (!mHelper.handleActivityResult(requestCode, resultCode, data))
Method is like this
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
It works great on a static response, but crashes when I buy from the market.