Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LicenseChecker errors with Android P

Tags:

android

I've set up licence checker based on this guide, and more particularly using this sample code, and it's been working fine for some time now.

But recently I've been getting crash reports from Android P devices with the following error:

java.lang.NoClassDefFoundError: 
  at com.google.android.vending.licensing.ServerManagedPolicy.d (ServerManagedPolicy.java:22)
  at com.google.android.vending.licensing.ServerManagedPolicy.a (ServerManagedPolicy.java:22)
  at com.google.android.vending.licensing.LicenseValidator.a (LicenseValidator.java:2)
  at com.google.android.vending.licensing.LicenseChecker$ResultListener$2.run (LicenseChecker.java:245)
  at android.os.Handler.handleCallback (Handler.java:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:280)
  at android.os.HandlerThread.run (HandlerThread.java:65)
Caused by: java.lang.ClassNotFoundException: 
  at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
  at com.google.android.vending.licensing.ServerManagedPolicy.d (ServerManagedPolicy.java:22)
  at com.google.android.vending.licensing.ServerManagedPolicy.a (ServerManagedPolicy.java:22)
  at com.google.android.vending.licensing.LicenseValidator.a (LicenseValidator.java:2)
  at com.google.android.vending.licensing.LicenseChecker$ResultListener$2.run (LicenseChecker.java:245)
  at android.os.Handler.handleCallback (Handler.java:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:280)
  at android.os.HandlerThread.run (HandlerThread.java:65)

From some testing on an Android P emulator, I wasn't able to reproduce the same error above, but I am finding that the signedData variable is being received as null in LicenseValidator.verify()... see code here. I could work around this by checking for null as per this post, but that is just avoiding the problem rather than solving it. Plus, I'm not even sure it is the same problem as the one being reported by users in my console (maybe it's specific to the emulator environment).

Can anyone shed any light on these errors, and offer a solution?

EDIT with more info:

  1. I have tried (without success) adding the following to proguard rules, in case proguard is stripping stuff it shouldn't: -keep class com.google.android.vending.licensing.** { *; }
  2. I have also tried (without success) enabling multidex in my build.gradle: multiDexEnabled true
  3. When I send an apk directly to a user, compiled in exactly the same form as submitted to the Play Store, there was no crash... only seems to be the Play Store version that crashes

Here is a deobfuscated crash log from the console (even though I always upload mapping files immediately, for some reason sometimes it says "this mapping file was uploaded after the crash", which really cannot be true because I do it immediately):

java.lang.NoClassDefFoundError: 
  at com.google.android.vending.licensing.ServerManagedPolicy.decodeExtras (ServerManagedPolicy.java:22)
  at com.google.android.vending.licensing.ServerManagedPolicy.processServerResponse (ServerManagedPolicy.java:22)
  at com.google.android.vending.licensing.LicenseValidator.handleResponse (LicenseValidator.java:2)
  at com.google.android.vending.licensing.LicenseValidator.verify (LicenseValidator.java:153)
  at com.google.android.vending.licensing.LicenseChecker$ResultListener$2.run (LicenseChecker.java:45)
  at android.os.Handler.handleCallback (Handler.java:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:193)
  at android.os.HandlerThread.run (HandlerThread.java:65)
Caused by: java.lang.ClassNotFoundException: 
  at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
  at com.google.android.vending.licensing.ServerManagedPolicy.decodeExtras (ServerManagedPolicy.java:22)
  at com.google.android.vending.licensing.ServerManagedPolicy.processServerResponse (ServerManagedPolicy.java:22)
  at com.google.android.vending.licensing.LicenseValidator.handleResponse (LicenseValidator.java:2)
  at com.google.android.vending.licensing.LicenseValidator.verify (LicenseValidator.java:153)
  at com.google.android.vending.licensing.LicenseChecker$ResultListener$2.run (LicenseChecker.java:45)
  at android.os.Handler.handleCallback (Handler.java:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:193)
  at android.os.HandlerThread.run (HandlerThread.java:65)
like image 426
drmrbrewer Avatar asked Dec 10 '18 22:12

drmrbrewer


1 Answers

AndroidManifest.xml

 ...
 <application
     ...
     <uses-library
         android:name="org.apache.http.legacy"
         android:required="false" />
 </application>
 ...
like image 108
user_MGU Avatar answered Nov 07 '22 16:11

user_MGU