patreek / marketbilling

Automatically exported from code.google.com/p/marketbilling
0 stars 0 forks source link

IabHelper.java NullPointerException in queryPurchases #142

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
STEPS TO REPRODUCE:

Cannot reproduce it programmately

EXPECTED OUTPUT:

Everything works

ACTUAL OUTPUT:

It crashes

NOTES:

Here's the line of code that make the app crashes: 
https://code.google.com/p/marketbilling/source/browse/v3/src/com/example/android
/trivialdrivesample/util/IabHelper.java#916

So in this case the context is null or the service is null.

Original issue reported on code.google.com by stermi on 6 Aug 2013 at 9:18

GoogleCodeExporter commented 8 years ago
happens if IabHelper.dispose() is called while queryInventoryAsync() is 
pending, making mService null.

Someone definitely sucks at cancelling async tasks.

dispose() should properly cancel running threads and/or await for their 
completion before nullifying mService. The easiest way is to spawn threads with 
an ExecutorService and use its facilities to cancel threads and await for 
completion.

Original comment by pujos.mi...@gmail.com on 24 Aug 2013 at 6:04

GoogleCodeExporter commented 8 years ago
This is caused if the Play App crashes. It can easily be reproduced:

1) Start your app, instantiate the IabHelper
2) Force-Stop the Play Store App through the system settings
3) Switch back to your app, and attempt to make a purchase or query the 
inventory. The mService member is nulled by the onServiceDisconnected callback 
on the ServiceConnection, and causes the NullPointerException.

Original comment by alex.suz...@endboss.ch on 24 Sep 2013 at 8:25