I am trying to get android licensing to work in my first Android
application.
I have followed the online guides and have integrated the LVL Code using the ServerManagedPolicy.
Regardless of what license test response I set in the developer console I almost always (9 times out of 10) get a LicenseResponse.RETRY. Because DEFAULT_MAX_RETRIES = "0"
this is always converted into NOT_LICENSED
I've tried:
- turning WiFi On / Off
- running paid apps I bought (they all work!)
- unplugging the usb
- running in a vm and my real phone
I always get the same result. On the few occasions that I've had a licensed response it has not had any of the extras attached to increase the max retries. I think this is the crux of the problem - the first time I try and license I have no retry or validity period toleration in the default settings.
How can I get this working reliably?
Edit 1
Found this in the logs. Does this imply there is a problem connecting to the android market app?
08-18 21:12:16.071: INFO/LICENSE(10852): checkLicense
08-18 21:12:17.271: INFO/LicenseChecker(10852): Binding to licensing service.
08-18 21:12:17.281: WARN/ActivityManager(80): Unable to start service Intent { act=licensing.ILicensingService }: not found
08-18 21:12:17.281: ERROR/LicenseChecker(10852): Could not bind to service.
08-18 21:12:17.301: INFO/LICENSE(10852): dontAllow
There are two things that might help you:
- Assuming you are using the Developer Console to simulate a response, it sometimes takes more than a few minutes to refresh the response you got from previous tries. So if you simulated a FAILED response, you probably need to wait for a while before you can receive a SUCCESS response. Sometimes even rebooting your device will not help so you just have to wait.
- The LVL mechanism has some issues and even on users' devices you might get a FAILED response when there is no internet connection for a while on the device, or some other network error. What I recommend is to have several retries on top of the LVL built-in retries as I found it can't be trusted and prone to errors. It would probably reduce the number of false-negative reports you'll get from your users...
Make sure that this is in your AndroidManifest:
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
That is required to run the check license code.
来源:https://stackoverflow.com/questions/7033066/cannot-get-android-market-licensing-lvl-working-reliably-almost-always-return