30

im'triyng to implement the Google Licensing Verification in a Android Studio made app. By following this lines: http://developer.android.com/google/play/licensing/setting-up.html seems tath:

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.

I've done this but the import of:

import com.google.android.vending.licensing.LicenseChecker;
import com.google.android.vending.licensing.LicenseCheckerCallback;

fail.. Searching on google i've been noticed that i need to modify the build.grade file on my project, but i can't find a specific solution.

How can I reference the LVL in my android studio project? There is some tutorial or example?

Thanks Lorenzo

Mohammad Imran
  • 3,264
  • 4
  • 23
  • 37
Cybergatto
  • 739
  • 2
  • 8
  • 15

4 Answers4

54
  1. In Android Studio, Tools-Android-SDK Manager
  2. In SDK Manager, in the extras section choose Google Play Licensing Library
  3. Go back to Android Studio, and choose File-New-Import Module
  4. ADK Manager will have put the downloaded files under your SDK directory, in my case Desktop/android-sdk-macosx/extras/google/play_licensing/library
  5. Choose to import this directory as a module, and give it a name. I used 'lvl'
  6. Optionally change targetSdkVersion in the lvl module's build.gradle to match your project targetSdkVersion.
  7. Then in your projects build.gradle, add the line compile project(':lvl') inside the {dependencies{ section.
  8. Re-sync Gradle and everything should compile correctly.
Nick Fortescue
  • 43,045
  • 26
  • 106
  • 134
22

Finally I've got the solution! You have to put the library/src/com directories in the youroject/scr/main/java/com and then click on the "Sync project with Gradle files" button.

Marcus Rickert
  • 4,138
  • 3
  • 24
  • 29
Cybergatto
  • 739
  • 2
  • 8
  • 15
  • That worked for me too. The official Android developer text: "copy (or import) the LVL's library/src/com directory into your application's src/ directory." isn't clear at all! – Chris Johnson Apr 20 '15 at 06:17
  • I combined this method with the one below, and was finally able to get it to recognize the library. Maybe we should start a kick starter for the Google documentation team, so they can hire a translator. lol Thanks everyone. – snapplex Jun 06 '15 at 22:32
  • 4
    If you are compiling for the 23 API, you have to include ``useLibrary 'org.apache.http.legacy'`` in the android configuration: http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client – redcrow Oct 09 '15 at 13:43
1

step 6 is placed in inside the project(":android"){dependencies { section.

Peter
  • 7
  • 2
  • 13
1

Copying the LVL sources to your application. 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. Visit:http://developer.android.com/google/play/licensing/setting-up.html