javaandroidandroid-lvl

Android License Test Response - Never works


I've been working on an Android App that has already been published to Google Play. For the next update (versionCode = 3) my client wants to include the LVL licensing scheme.

The first thing I did was set up a static test response from the licensing server. I set the test response to LICENSED. After reading this in the documentation:

This License Test Response will be sent to devices using [my email address] or the Test Accounts listed above for applications you have uploaded to Google Play. >Additionally, this account (but not the Test Accounts) will receive this response for >applications that have not yet been uploaded to Google Play.

I thought, not a problem, since my developer account email is the same as my Google Play account email on my testing devices. So I should receive the test response when debugging the App.

After that, I read through all the other licensing documentation and sample code and integrated it into the App. I used a ServerManagedPolicy with the correct base64 public key and 20 random generated bytes as the salt.

Once everything looked good I uploaded it to the device to test it, but instead of receiving the LICENSED response that I expected, I am always receiving a NOT_LICENSED response. I went back and made sure that:

  1. I was connected to the internet.
  2. I was signed in to my developer account on Google Play.
  3. The LicenseChecker was using the correct public key.
  4. Clearing my Google Play cache.

At first, I thought maybe it had something to do with the caching, so I tried using a StrictPolicy instead. Same response. Since I haven't purchased the App from the store, I'm under the impression that the licensing server is responding normally instead of sending the static test response. Here are some other things I have tried:

  1. Waiting 24 hours and trying again.
  2. Tried building the App with the android debug key, as well as the current distribution key.
  3. Setting up and using a different test user account on Google Play. I made sure to add this email account to the 'Test accounts' section in the developer console.
  4. Uploading the APK to Google Play, but not publishing it.
  5. Incrementing the versionCode from 2 to 3. This is interesting, because instead of responding NOT_LICENSED it returns the 'application error code' ERROR_NOT_MARKET_MANAGED.

This leads me to believe that the license server is always responding normally, instead of sending the static test response I set up to my developer account. I have a feeling it may be because the App is already published, but I cannot risk publishing a debug build just to test wether or not it is working.

Has anyone been in this situation before? Any help is greatly appreciated.


Solution

  • I've spent hours and even days with the same problem, it is documented here and elsewhere, that pre-published license test is hit and miss, and more miss than hit from what I discovered.

    The only way I've found to make it work "more reliably" (but still not totally reliable) is to have a hardware device that is a reset to factory defaults, then set it's PRIMARY google user as the same one as your dev account that has the app uploaded to test with.

    The special AVDs are also not very reliable.