App Licensing

Google Play offers a licensing service that lets you enforce licensing policies for applications that you publish on Google Play. With Google Play Licensing your application can query Google Play at runtime to obtain the licensing status for the current user, then allow or disallow further use as appropriate.

The licensing service is a secure means of controlling access to your applications. When an application checks the licensing status, the Google Play server signs the licensing status response using a key pair that is uniquely associated with the application. Your application stores the public key in its compiled .apk file and uses it to verify the licensing status response.

Any application that you publish through Google Play can use the Google Play Licensing service. No special account or registration is needed. Additionally, because the service uses no dedicated framework APIs, you can add licensing to any application that uses a minimum API level of 3 or higher.

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

Using the Google Play Developer Console, you can:

  • Obtain an app-specific public key for licensing
  • Debug and test an application's licensing implementation, prior to publishing the application
  • Publish the applications to which you have added licensing support


To check App License Status for your App subscribe to

AN_LicenseManager.OnLicenseRequestResult += LicenseRequestResult;

You can get Base64String Public Key in GoogleDeveloper Console in the Services & APIs page as shown below:

If you use the method without base64key parameter, it will be retrieved from the plugin settings:


AN_LicenseManager.OnLicenseRequestResult += LicenseRequestResult;

private void LicenseRequestResult(AN_LicenseRequestResult result) {
	AndroidMessage.Create("License Check Result: ", "AN_LicenseRequestResult: " +  result.ToString());

From AN_LicenseRequestResult you can get Status and Error:

public enum AN_LicenseStatusCode {
public enum AN_LicenseErrorCode {

Description of possible AN_LicenseRequestResult values:

  • RESULT_LICENSED - The application is licensed to the user. The user has purchased the application or is authorized to download and install the alpha or beta version of the application.
  • RESULT_RETRY - If the reason received from the policy is RETRY, it was probably due to a loss of connection with the service, so we should give the user a chance to retry. So, show a dialog to retry.
  • RESULT_NOT_LICENSED - The user is not licensed to use this app. Your response should always inform the user that the application is not licensed but your behavior at that point can vary. You might provide the user with a limited access version of your app or you can take them to Google Play to purchase the app.
  • ERROR_CHECK_IN_PROGRESS - Application checking in Google Play is in progress.
  • ERROR_INVALID_PACKAGE_NAME - Local error — the application requested a license check for a package that is not installed on the device.
  • ERROR_INVALID_PUBLIC_KEY - Provided public key is invalid.
  • ERROR_MISSING_PERMISSION - Application permission for License Checking is missing inside AndroidManifest file.
  • ERROR_NON_MATCHING_UID - Local error — the application requested a license check for a package whose UID (package, user ID pair) does not match that of the requesting application.
  • ERROR_NOT_MARKET_MANAGED - Server error — the application (package name) was not recognized by Google Play. Can indicate that the application was not published through Google Play.
  • ERROR_UNKNOWN - An unknown error occurred.

You can use Playmaker actions to implement license check as well.

An example of API use can be found in AnOtherFeaturesPreview.cs file.

Example Scene:

Plugins -> StansAssets -> Modules -> AndroidNative -> xExample -> Scenes -> Other -> OtherFeatures