Eymir / marketbilling

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

NullPointerExceptions calling IMarketBillingService #25

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
STEPS TO REPRODUCE:
1. Not happening in my tests, but multiple errors reported by live applications 
via ACRA

EXPECTED OUTPUT:

Calling IMarketBillingService.sendBillingRequest() should return without error.

ACTUAL OUTPUT:

NullPointerException in some cases (different OS versions)

AFFECTED ORDER IDS (IF RELEVANT): N/A

OS VERSION:

2.2.1
3.0.1
2.1-update1
1.6
2.3.4
2.2.1

MARKET/MYAPPS VERSION: N/A

DEVICE:

HTC Wildfire
A500
MB525
U20i
HTC HD2
GT-S5660

OUTPUT FROM ADB BUGREPORT ATTACHED:

Stacktrace from ACRA:

java.lang.NullPointerException 
   at android.os.Parcel.readException(Parcel.java:1253) 
   at android.os.Parcel.readException(Parcel.java:1235) 
   at com.android.vending.billing.IMarketBillingService$Stub$Proxy.sendBillingRequest(IMarketBillingService.java:100)

NOTES:

The 'Upgrade' button that calls sendBillingRequest() is only enabled if   
CHECK_BILLING_SUPPORTED returns RESULT_OK.

Original issue reported on code.google.com by nikolay....@gmail.com on 23 May 2011 at 11:29

GoogleCodeExporter commented 9 years ago
We too are getting this error reported by users.  We're unsure how to reproduce 
it.  Any hints greatly appreciated.

Original comment by mike.jim...@gmail.com on 2 Jun 2011 at 2:29

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I noticed that this stack trace is produced when you clear all data from the 
Market app and try to use in-app purchases without first initializing the 
Market app (there's some kind of opt-in step the first time you start the 
Market app).

Original comment by mike.jim...@gmail.com on 14 Jun 2011 at 8:15

GoogleCodeExporter commented 9 years ago
I can't really prove it, but there must be other cases too. It's unlikely that 
people will clear the Market app data after downloading the app. In any case if 
the Market or in-app billing is not available, it should return 
BILLING_NOT_AVAILABLE or some other relevant error code, not crash with a NPE.

Original comment by nikolay....@gmail.com on 15 Jun 2011 at 1:19

GoogleCodeExporter commented 9 years ago
I am facing the same NPE but only client side when I sending build for testing 
it is not produced on my side so its bizarre to know what is happening, For 
testing purpose on client side I sending this

mBillingService.requestPurchase("android.test.purchased", null); 

and below is my stacktrace from ACRA might someone find useful 

"java.lang.NullPointerException
    at android.os.Parcel.readException(Parcel.java:1266)
    at android.os.Parcel.readException(Parcel.java:1248)
    at com.android.vending.billing.IMarketBillingService$Stub$Proxy.sendBillingRequest(IMarketBillingService.java:100)
    at com.market.BillingService$RequestPurchase.run(BillingService.java:230)
    at com.market.BillingService$BillingRequest.runIfConnected(BillingService.java:119)
    at com.market.BillingService.runPendingRequests(BillingService.java:542)
    at com.market.BillingService.onServiceConnected(BillingService.java:579)
    at android.app.ActivityThread$PackageInfo$ServiceDispatcher.doConnected(ActivityThread.java:1247)
    at android.app.ActivityThread$PackageInfo$ServiceDispatcher$RunConnection.run(ActivityThread.java:1264)
    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:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    at dalvik.system.NativeStart.main(Native Method)
"

Original comment by ingsaur...@gmail.com on 24 Jun 2011 at 4:58

GoogleCodeExporter commented 9 years ago
This seems to happen when you pass null as second argument to requestPurchase. 
Do not use something that might be null - unfortunately, the Secure.ANDROID_ID 
can be null on some devices:

String android_id = 
Secure.getString(PersonsListActivity.this.getContentResolver(),
                        Secure.ANDROID_ID); // could be null!
if (!mBillingService.requestPurchase("unlimitedpayments", android_id)) { // 
crashs with NPE
    showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
}

My solution is to use the Wifi MACAdress if Secure.ANDROID_ID is null:

WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = manager.getConnectionInfo();
String MACAddress = wifiInfo.getMacAddress();

Original comment by francois...@gmail.com on 5 Jul 2011 at 7:47

GoogleCodeExporter commented 9 years ago
The second parameter is the developer payload, which is optional, and thus 
allowed to be null. Unless you changed something in BillingService, ANDROID_ID 
being null is unrelated to this issue.

Original comment by nikolay....@gmail.com on 5 Jul 2011 at 8:02

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
You seem to be right - according to javadoc, developer payload is optional and 
allowed to be null.

I referenced commment 5, which seems to be able to reproduce the error with

mBillingService.requestPurchase("android.test.purchased", null); 

...I'm getting this exception too and would be happy to know the -correct- 
solution.

Right now, I'm doing an ugly try / catch and falling back to the regular Market.

Original comment by francois...@gmail.com on 5 Jul 2011 at 9:09

GoogleCodeExporter commented 9 years ago
This happens when the device has not accepted the License Agreement and try to 
call this line I encountered this problem when my client just bought a new 
device and try run my app which make use of inApp so he didnt ever opened 
market app in his device and so had never accepted the Agreement once you 
accept the it this error will not be there

mBillingService.requestPurchase("android.test.purchased", null); 

Now for real life scenario your app if installed from market there cant be any 
scenario he hasnt accepted that agreement so in practice once your app is 
published your app will never throw such exception. And if you want to 
reproduce the problem follow comment 1

Original comment by ingsaur...@gmail.com on 5 Jul 2011 at 9:21

GoogleCodeExporter commented 9 years ago
Just a thanks, was pulling my hair out, coulnt work out why my app broke after 
I did a factory reset and went straight to a debugger without market first!

Google Fodder

"sendBillingRequest null exception"
How to fix "sendBillingRequest null exception" 
As above, check the device has accessed the market at least once.

Original comment by bher...@gmail.com on 4 Aug 2011 at 5:02

GoogleCodeExporter commented 9 years ago
Yeah, I was a bit concerned as well, although this isn't exactly ideal. Some 
users won't necessarily go to the market first, and will blame this on the app, 
when it's clearly not at fault.

Is there a reason why it can't prompt the terms of service when it opens up 
after the user clicks to purchase something?

Original comment by andr...@jogonaut.com on 6 Sep 2011 at 2:20

GoogleCodeExporter commented 9 years ago
Really similar, but happening even earlier - on checkBillingSupported call at 
the very start of my application.

Note: I have hidden with asterisk my app package.

java.lang.NullPointerException
at android.os.Parcel.readException(Parcel.java:1327)
at android.os.Parcel.readException(Parcel.java:1275)
at 
com.android.vending.billing.IMarketBillingService$Stub$Proxy.sendBillingRequest(
IMarketBillingService.java:100)
at *.BillingService$CheckBillingSupported.run(BillingService.java:191)
at *.BillingService$BillingRequest.runIfConnected(BillingService.java:120)
at *.BillingService.runPendingRequests(BillingService.java:547)
at *.BillingService.onServiceConnected(BillingService.java:584)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1058)
at 
android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1075)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)

Any ideas on solving the issue?

Original comment by krzyszto...@blstream.com on 16 Sep 2011 at 12:35

GoogleCodeExporter commented 9 years ago
I see the same problem as #13.
It started occuring last week or so.

Original comment by kenneth@hexad.dk on 4 Oct 2011 at 10:18

GoogleCodeExporter commented 9 years ago
I have experienced the exactly same error as described here. Just put a very 
ugly try catch, could I find another and more "lean" solution to it!?
My IAP manager is basically the same as the one used in the Dungeon example.

Thx!

Original comment by pekay...@gmail.com on 10 Oct 2011 at 8:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This error occurs if the user isn't logged on the phone in Google account

Original comment by sashscor...@gmail.com on 12 Oct 2011 at 1:18

GoogleCodeExporter commented 9 years ago
To repro this issue, you can delete user data from the market application, 
effectively removing acceptance of the EULA.  Settings->applications->manage 
applications->market->clear data.

Original comment by moblyng...@gmail.com on 26 Oct 2011 at 9:41

GoogleCodeExporter commented 9 years ago
This for sure occurs when the Market EULA has not been accepted. This error can 
occur after a Market upgrade has taken place as this also causes the EULA data 
to be cleared. This means that if your app has been running perfectly and a 
Market place upgrade occurs which the users may not have looked at and hence 
accepted the EULA that you app will keep crashing until they get round to 
accessing the Market place and accepting the EULA. By this time your app may 
have been given a very poor rating (after all it crashes all the time), you may 
have spent hours trying to reproduce the bug, your app may be deleted and it's 
all because Google reset the EULA.

Come on Google, this is a bug, please fix it urgently as it affects revenue for 
all of us!!!

Original comment by j.robin....@gmail.com on 29 Oct 2011 at 8:05

GoogleCodeExporter commented 9 years ago
I have implemented the following work around that I have placed around ALL 
calls to the  billing interfaces. This is not neat but it does seem to work. I 
have used an alert as this makes sure that the user is aware that the problem 
lies with the Android Market and not my application (for me this code is always 
in an activity so that the context to the dialog is available):

  try {
    CALL BILLING CODE HERE .....
  } catch (NullPointerException e) {
    initialiseMarket();
  }

private void initialiseMarket() {
  new AlertDialog.Builder(this).
    setTitle("Android Market").
    setNeutralButton("CLOSE"), new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search"));
        startActivity(intent);
      }
    }).
    setMessage("Android Market not initialised. Please accept EULA and restart.").
    show();
}

Original comment by j.robin....@gmail.com on 29 Oct 2011 at 9:49

GoogleCodeExporter commented 9 years ago
The not-yet-accepted EULA is not the only cause of this NPE. I have an N1 
(2.3.6) user in China who has definitely accepted the EULA (indeed, they get to 
the main Market app screen) who is also getting this NPE.

Original comment by mjc1...@gmail.com on 1 Nov 2011 at 3:14

GoogleCodeExporter commented 9 years ago
Can anyone confirm that this is still the case with the latest version of 
Market app 3.3.11? I currently cannot reproduce this EULA bug...

Original comment by mjc1...@gmail.com on 4 Nov 2011 at 12:55

GoogleCodeExporter commented 9 years ago
I've been running some tests and here is what I'm getting when the EULA has not 
been accepted:

Market app 3.1.5 (N1 2.3.6): CheckBillingSupported returns 
RESULT_BILLING_UNAVAILABLE and requestPurchase leads to the NPE described in 
this thread.

Market app 3.3.11 (HTC Hero 2.2): CheckBillingSupported returns RESULT_OK and 
requestPurchase() can proceed as desired.

These tests aren't very scientific so would be interested to hear if others are 
also experiencing this.

Original comment by mjc1...@gmail.com on 4 Nov 2011 at 1:29

GoogleCodeExporter commented 9 years ago
I've found another cause of this exception besides not excepting the EULA. The 
following scenario occurs on a Samsung Galaxy Tab 10.1.

The standard tablet market is version 1.X, whereas the latest phone markets are 
v3.1.X. If you manually download and install the 3.1.X market apk onto the 
Samsung Tab then you will see two markets. Both will appear to work and you can 
download apps from both. However once the 3.1.X market is installed, any time 
an app hits the line 
com.android.vending.billing.IMarketBillingService$Stub$Proxy.sendBillingRequest 
it throws the readException reported above. I found this consistenty across 
several apps including Wind Up Knight and other games.

I found the issue by factory resetting my tab and then trying Wind Up Knight 
before and after installing the 3.1.X market with the readException starting as 
soon as it was installed. I used Apps Explorer to uninstall the 3.1.X market 
and after this Wind Up Knight started to work again.

Hope this helps.

Original comment by samsungt...@gmail.com on 20 Nov 2011 at 11:23

GoogleCodeExporter commented 9 years ago
Market app 3.4.4
Os version 2.3.3
Galaxy S 2
EULA accepted, but 
java.lang.NullPointerException
at android.os.Parcel.readException(Parcel.java:1328)
at android.os.Parcel.readException(Parcel.java:1276)
still exists
at .sendBillingRequest call

Original comment by istar...@gmail.com on 25 Feb 2012 at 6:57

GoogleCodeExporter commented 9 years ago
This just started happening 2 hours ago in my app, I've gotten 70 exception 
reports within the last 2 hours. What on earth is happening!? The app's been 
working great for months (since April) until just now..

java.lang.NullPointerException
        at android.os.Parcel.readException(Parcel.java:1328)
        at android.os.Parcel.readException(Parcel.java:1276)
        at com.android.vending.billing.IMarketBillingService$Stub$Proxy.sendBillingRequest(IMarketBillingService.java:100)
        at inapp.billing.BillingService$RequestPurchase.run(BillingService.java:231)
        at inapp.billing.BillingService$BillingRequest.runIfConnected(BillingService.java:120)
        at inapp.billing.BillingService$BillingRequest.runRequest(BillingService.java:97)
        at inapp.billing.BillingService.requestPurchase(BillingService.java:444)
        at inapp.billing.EmergencyButtonInAppBilling.openMarketPurchaseActivity(EmergencyButtonInAppBilling.java:96)
        at inapp.billing.EmergencyButtonInAppBilling$1.onClick(EmergencyButtonInAppBilling.java:126)
        at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:163)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:130)
        at android.app.ActivityThread.main(ActivityThread.java:3701)
        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:866)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
        at dalvik.system.NativeStart.main(Native Method)

Original comment by ubershmekel@gmail.com on 12 Aug 2012 at 4:06

GoogleCodeExporter commented 9 years ago
Quoting from above:

"This happens when the device has not accepted the License Agreement and try to 
call this line I encountered this problem when my client just bought a new 
device and try run my app which make use of inApp so he didnt ever opened 
market app in his device and so had never accepted the Agreement once you 
accept the it this error will not be there"

You need to modify your app to catch the exception (and ideally let them know 
that the License Agreement needs to be signed, or if it's a Samsung tablet, 
then let them know the other issue listed above). It's the only way unless they 
fix the core bug in Android.

Original comment by tim.men...@gmail.com on 12 Aug 2012 at 4:29

GoogleCodeExporter commented 9 years ago
Please check the implement of sendBillingRequest in service side. The remote 
service throw the Runtime Exception and re-write the Exception to Client. Your 
app's data may have problem, the Service itself may also have bug.

Original comment by Suu...@gmail.com on 1 Feb 2013 at 2:16

GoogleCodeExporter commented 9 years ago
Really useless app.

Original comment by dimasma...@gmail.com on 19 Feb 2014 at 10:52