Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException at net.robotmedia.billing.BillingController.startPurchaseIntent #53

Open
GiuseppeIuculano opened this issue Dec 10, 2011 · 3 comments

Comments

@GiuseppeIuculano
Copy link

Hi,

I'm seeing a lot of NullPointer Exception:

java.lang.NullPointerException
at net.robotmedia.billing.BillingController.startPurchaseIntent(SourceFile:564)
at net.robotmedia.billing.helper.AbstractBillingObserver.onPurchaseIntent(SourceFile:58)
at net.robotmedia.billing.BillingController.onPurchaseIntent(SourceFile:324)
at net.robotmedia.billing.BillingRequest$RequestPurchase.processOkResponse(SourceFile:128)
at net.robotmedia.billing.BillingRequest.getRequestType(SourceFile:240)
run
at net.robotmedia.billing.BillingService.runRequest(SourceFile:246)
at net.robotmedia.billing.BillingService.runPendingRequests(SourceFile:226)
at net.robotmedia.billing.BillingService.onServiceConnected(SourceFile:147)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1064)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1081)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3647)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

@zander-berg
Copy link

Hey,

I also had quite a lot of those Exception. I figured out that many of them came from Google Play Store responses without a notificationId. If the response comes from a refunded or canceled purchase, the plugin won't know about bit and try to confirm a 'null' id. Here's my proposed fix which seems to get rid of some of these Exceptions:

In BillingController.java, function onPurchaseStateChanged you see the following (approx. line 422)

            if (p.notificationId != null && automaticConfirmations.contains(p.productId)) {
                confirmations.add(p.notificationId);
            } else {
                // TODO: Discriminate between purchases, cancellations and
                // refunds.
                addManualConfirmation(p.productId, p.notificationId);
            }

Replace by:

            if (p.notificationId != null && automaticConfirmations.contains(p.productId)) {
                confirmations.add(p.notificationId);
            } else {
                // TODO: Discriminate between purchases, cancellations and
                // refunds.
                if (p.notificationId != null) {
                    addManualConfirmation(p.productId, p.notificationId);
                }
            }

Hope that helps a little.

@shah0664
Copy link

Hi,

That Replaced code works for u or not , as i am experiencing the same issue.

@zander-berg
Copy link

hey, sorry for the late response.

the replaced code above makes the code much more stable in my case. there are still very rare crashes of the billinglibrary, but the app has been released and in-app purchases are running fine without customer complaints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants