How to Set Up Google Play Licensing in Android Studio

Google Play Licensing
News / Mobile Development

How to Set Up Google Play Licensing in Android Studio

 

Setting Up for Licensing

Before starting to set up Google Play Licensing there are several things you would need to do first. Setting up your Google Play publishing account, the development environment and test accounts is the first step to take before adding your license verification.

Setting-Up a Publisher Account

If you do not have already got a publisher account for Google Play, you would like to register for one using your Google account and comply with the Google Play terms of service.

If you have already got a publisher account on Google Play, use your Play Console to line up licensing.

Using the Google Play Console, you can:

  • Obtain a key for licensing
  • Before publishing test and debug the license
  • After adding license support- publish the application
  • Administrative settings for licensing
  • Through the Play Console, you can manage several administrative accounts for licensing

The controls let you:

You are able to set up several testing accounts using email addresses. It is possible while using the licensing server to send checks and receive static test responses.

You can add configuration to the static test responses that the server sends from a user signed in to the publisher account or a test account. You can set test responses within the Account Details page of the Play Console.

Obtain the app’s public key for licensing. When you are implementing licensing in an application, you want to copy the general public key string into the appliance. You can find the option for obtaining the licensing key on the Services & APIs page – All Applications.

Setting Up the Development Environment

  • Runtime environment set-up
  • Downloading the LVL into your SDK
  • Setting up the Licensing Verification Library
  • Add the LVL project library

Setting up the runtime environment

To debug and test licensing in your application, you would like to line up a runtime environment that has the required Google Play service, in order that your application is in a position to send license check requests to the licensing server.

Updating your project configuration

After you found out a runtime environment that meets the wants described above — either on an actual device or on an emulator — confirm to update your application project or build scripts as required, in order that your compiled .apk files that use licensing are deployed into that environment. In particular, if you are developing in Android Studio, make sure that you set up a Run/Debug Configuration that targets the appropriate device or AVD.

You wouldn’t need to re-configure your app, as long as the project is already configured to compile against a typical Android 1.5 (API level 3) or higher library. Adding licensing to an application should haven’t any impact whatsoever on the application’s build configuration.

Downloading the LVL

The License Verification Library (LVL) has helper classes that greatly simplify the work that you simply got to do to feature licensing to your application.

You can clone the LVL repository and set it as a library project. Clone the repository by getting it from:

git clone https://github.com/google/play-licensing

Setting Up the Licensing Verification Library

After downloading the LVL to your computer, you would like to line it up in your development environment, either as an Android library project or by copying (or importing) the library sources directly into your existing application package. In general, using the LVL as a library project is suggested, since it allows you to reuse your licensing code across multiple applications and maintain it more easily over time. Note that the LVL isn’t designed to be compiled separately and added to an application as a static .jar file.

The recommended way of using the LVL is to set it up as a replacement Android library project. Other Android application projects can reference the library project and, at build time, include its compiled sources in their .apk files.

Once you’ve downloaded the LVL, you are able to start using it directly since it is provided as a configured library.

If you are working in Android Studio, you need to add the LVL to your project as a new module.

Use the “Import-Module from Source” window to import a library module by selecting File > New > Import-Module.

In the Import-Module from Source window, in the Source directory, enter the LVL’s library directory (the directory containing the library’s AndroidManifest.xml file) as the project root (/extras/google/play_licensing/library/AndroidManifest.xml), then select Next.

Select Finish to import the library module.

Add the LVL library to your application

If you would like to use the LVL sources as a library project, you would like to feature a reference to the LVL library project in your application project properties. This tells build tools to incorporate the LVL library project sources in your application at compile time. The process for adding a reference to a library project depends on your development environment, as described below.

 

Source:

Leave your thought here

Your email address will not be published.

17 − sixteen =