fredlala8 / marketbilling

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

IabHelper causes NullPointerException when launched on a simulator #164

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
STEPS TO REPRODUCE:
1. Implement a test application and launch it on a simulator
2. Observe that test application craches with NullPointerException
3. That happens because startSetup() function doesn't take into account that 
PackageManager's function queryIntentServices may return null.
I realize that it is not a good idea to run in-app billing code on a simulator, 
but anyway, if it crashes, then it would be better to do that gracefully.
I would suggest to at least change line 217 from:

if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 
0).isEmpty())) {

to:

if ((mContext.getPackageManager().queryIntentServices(serviceIntent, 0) != 
null) && (!mContext.getPackageManager().queryIntentServices(serviceIntent, 
0).isEmpty())) {

EXPECTED OUTPUT: If a helper fails to do any action, it is supposed to return 
an error code, or at least expected exception

ACTUAL OUTPUT: NullPointerException

AFFECTED ORDER IDS (IF RELEVANT): n/a

OS VERSION: Simulator R18

MARKET/MYAPPS VERSION: n/a

DEVICE: Simulator

OUTPUT FROM ADB BUGREPORT ATTACHED:
(Note: The output from "adb bugreport" is required for all bug reports.)
n/a

NOTES:
n/a

Original issue reported on code.google.com by Denis.M....@gmail.com on 20 Nov 2013 at 11:55

GoogleCodeExporter commented 8 years ago
Sorry, this ticket seems to be duplicate of 
http://code.google.com/p/marketbilling/issues/detail?id=158

Original comment by Denis.M....@gmail.com on 20 Nov 2013 at 2:00