6

I just followed the standard Android licence checking procedure, and recently I get these reports:

java.lang.NullPointerException
at com.google.android.vending.licensing.LicenseValidator.verify(LicenseValidator.java:99)
at com.google.android.vending.licensing.LicenseChecker$ResultListener$2.run(LicenseChecker.java:228)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)

What could this mean? Is this normal ? I never got this before. Since the app in question is becoming more popular - could this be an indication that someone tried to crack the app somehow to avoid paying?

Many thanks for your insights!

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
user387184
  • 10,953
  • 12
  • 77
  • 147

2 Answers2

13

This exception is usually encountered, when the device doesn't have the Google Play app installed or there is no account registered with the default. One might get this exception when the have the old Google Market application.

You can check the issue here, as well: http://code.google.com/p/android/issues/detail?id=26722

thursdaysDove
  • 542
  • 7
  • 7
  • 1
    Workaround to avoid dump? A way to detect this and display a message? – powder366 Jan 09 '15 at 13:19
  • Just tried removing all accounts but didn't experience this bug, the app still thinks it has the license. Also if Google Play was not installed on the phone how this exception was reported back to Google Play developer console? – petrsyn May 17 '17 at 23:36
7

I know this is an old question but I had this error NPE on a couple of test devices and added this quick fix:

    AccountManager am = AccountManager.get(context);
    int numAccounts = am.getAccountsByType("com.google").length;

    if(numAccounts == 0) {
        noAccountDialog();
    } else {
        // Do the license check as you have an account
    }

You will need GET_ACCOUNTS permission in AndroidManifest.xml

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
philask
  • 790
  • 9
  • 12
  • Hmmm, AccountManager cannot be resolved. import android.accounts.AccountManager also can't be resolved. What's the trick to make this work? – Brian Knoblauch May 13 '14 at 14:37
  • Nevermind, got it. Apparently that was added in API level 5 and I'm working on an API level 4 app... "It's never easy" :-) – Brian Knoblauch May 13 '14 at 14:39
  • people tend to freak out when they see the GET_ACCOUNTS permission. It is presented as basically "application can read all of your account and personal information". Not an option for me unfortunately. – ShellDude Dec 14 '17 at 00:26