Crash with null pointer exception after Billing Service gets disconnected
See original GitHub issueAfter successful setup and the establishment of a connection to the Billing Service in
IabHelper.startSetup()
The user tries to make an in-app purchase.
IabHelper.launchPurchaseFlow()
gets called which in turn calls methods on mService
. But sometimes
IabHelper.onServiceDisconnected()
has been called in the meantime which sets
IabHelper.mService = null
This causes a null pointer exception.
It seems unpredictable when/why this disconnection happens. But I have some pre-launch reports in my developer console as examples.
Would be resolved by: https://github.com/googlesamples/android-play-billing/pull/46
Issue Analytics
- State:
- Created 7 years ago
- Comments:24 (1 by maintainers)
Top Results From Across the Web
Java for Android Null Pointer Exception on ... - Stack Overflow
The exact error message I'm getting is "Attempt to invoke interface method 'android.os.Bundle com.android.vending.billing.IInAppBillingService.
Read more >How to Fix and Avoid NullPointerException in Java - Rollbar
The NullPointerException occurs due to a situation in application code where an uninitialized object is attempted to be accessed or modified.
Read more >Crashes - Android Developers
Null pointer exceptions are the largest cause of app crashes on Google Play. The purpose of null is to signify that the object...
Read more >Troubleshoot node crashes in Amazon OpenSearch Service
Each OpenSearch Service node runs on a separate Amazon Elastic Compute Cloud (Amazon EC2) instance. A failed node is an instance that isn't ......
Read more >Minecraft Server Errors - Apex Hosting
However, there are endless error codes that may appear on your server and it ... be displayed in a crash report as follows:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Does it say this somewhere clearly? Presumably it should. Its amazing how confusing the documentation is.
billing_integrate.html still describes using the old IabHelper and IInAppBillingService.aidl
Whereas for example billling_library.html describes using the new BillingClient.
The github example both reference, contains both a “TrivialDrive” and “TrivialDrive_v2” subdir, each of which simply describe themselves as
Even though billing/versions.html shows version 5 to be current since Feb 2015 TrivialDrive_v2 doesn’t state how/why it differs from TrivialDrive, and why TrivialDrive is still there at all (is TrivialDrive obsolete? Are there valid reasons to still use TrivialDrive? Is TrivialDrive_v2 not finished yet?)
And this on top of how hard it is to get the sample working anyways (setting up your own in-app products in developer console, modifying the app to reflect this, only working with signed release etc). A bit more clarity here could save many 1000s of developers many frustrating hours
billling_library.html feels unfinished as well.
Why does the chapter ‘Retrieve existing purchases’ describe and show ‘Google Play calls the onPurchasesUpdated() method to deliver the result of the purchase operation’? How is this relevant? Is it called on service connect?
Only in the last sentence it states: ‘You can also query Google Play to quickly retrieve the list of purchases and subscriptions that the user made.’ It fails to mention how.
Three chapters down we learn you should use
queryPurchases()
and could usequeryPurchaseHistoryAsync()
but neither triggers above callback.The difference between these two methods is also not explained in depth. The first uses the local Play Service cache, the second does some kind of net call but is only able to retrieve the very last transaction. When is the cache refreshed? Is there a use case for the seconds method? Is the first unsafe?
I tried to re-implement billing because of the NPEs. I hate trial and error, and not just the annoying, impossible to really test billing. The docs suck. I’m irritated.