user1091524
user1091524

Reputation: 865

Include LVL Google Licensing in Android Studio App

I followed the instructions here http://developer.android.com/google/play/licensing/setting-up.html#add-library

Specifically the part that says "As an alternative to adding the LVL as a library project, you can copy the library sources directly into your application. To do so, copy (or import) the LVL's library/src/com directory into your application's src/ directory.

If you add the LVL sources directly to your application, you can skip the next section and start working with the library, as described in Adding Licensing to Your App."

The com folder shows up under src but when I go to add the imports it highlights 'vending" in red and says 'symbol cannot be resolved'. I copied the import statements directly from the web page listed above. You'll notice I manually added .utils to the first import, thinking maybe the path was incomplete.

What did I miss?

Greg

enter image description here

EDIT I've read a few more articles that give "solutions" that don't work for me. Ugh! I've been at this for 4 hours and I am no where closer than when I started. I've tried copying the folders in to my project several times, starting with different folder levels of the licensing source files. Each time 'vending' is an unknown symbol.

I tried importing the library, but that hosed things up. 'vending' still turned red, but now so did 'ActionBarActivity' and I couldn't sync the gradel. AS then forced me to download a new version of the SDK Build-Tools. I think it was 19.1. That didn't solve any problems. I undid all of the changes and I'm back to where I started.

In looking at the sample project I noticed the structure of the source files is very different and I can't figure out how to add the licensing library to my project so it looks like the sample.

enter image description here

EDIT2: I read this article (http://www.codeproject.com/Tips/607552/How-to-add-external-library-file-in-Android-Studio) which was specific to AS and not Eclipse. That said to add the files to the lib folder. I was to then right-click over them and choose "Add as library". Sadly, Add as library is not an option in AS 1.0.2. This did, however, make it so 'vending' was recognized as a symbol, but now 'LicenseChecker' and 'LicenseCheckerCallback' are not recognized.

I think that might be progress, but I'm not thinking I will just give the app away instead of trying to charge 99 cents for it. I could publish today, if not for this.

EDIT3: Setting Up the Licensing Verification Library on Android Studio Same exact problem, but that didn't work. Crazy frustrating!

Upvotes: 3

Views: 3961

Answers (1)

DevByStarlight
DevByStarlight

Reputation: 1070

Apologies:

  • This is, unfortunately, not an answer to the question.
  • However, I mention the following so you don't feel you are banging your head against something which should be working but, apparently, is not.

FWIW: I believe the steps you are following are generally correct. I have been (had been) using the LVL successfully up until the ADK API 22 release when "something broke". Since then I get the same "Error contacting licensing server" timeout error even though I had not changed anything. Same problem before and after I updated the LVL project.

~~

Incidentally, I'm fairly certain Android QA has not been using/testing the LVL library recently.

More specifically, LVL on Lollipop.

The LVL library contains a bug which immediately crashes the app when used - throws runtime exception about explicit instents. It attempts to bind to the vending service using a non-explicit intent. This is no longer allowed on Lollipop.

In particular, ./src/com/google/android/vending/licensing/LicenseChecker.java (approx line 130)

This bug has been present in the SDK since at least Sept 2014 in the API L preview release.

~~

I have a workaround for that bug to make the intent explicit. And it has been working fine until [roughly] the API 22 release when the server connect failure happened.

One might wonder just how, exactly, something as critical as license validation escaped QA testing before Lollipop Preview shipped let alone in the six months and to ADK API releases since then.

If the LVL library itself has been overlooked then it's not entirely unlikely the LVL server has not received attention either and the failure to connect might be a result of incompatibilty or something else in the LVL is not working properly.

~~

For the moment, I've disabled the LVL.

Which is extremely unfortunate because I need it to query for the Expansion Pack URLs when/if they fail to install. That happens roughly 1% of the time due to network hiccups, etc. No big deal but the LVL is where we get the URLs to handle re-downloading the expansion packs.

~~

Consequently, I will be investigating this further and will post if I discover a solution.

~~

[Edit]

Looks like someone else got it to work: (However, I still get 'error contacting licensing server' timeouts)

Upvotes: 4

Related Questions