Android Licensing SDK – Quick Start Guide

Summary

Quixxi Licensing SDK is usable by enterprises and mobile app developers to protect the distribution of paid apps on Google Play Store, Samsung Galaxy Apps and Amazon Appstore. You can track and block the usage of your paid app whenever it is not the one provided by these recognized stores
IMPORTANT – this framework applies ONLY on paid apps, with or without in-app purchases. But if you have a freemium model – i.e. a free app whose revenue is based on in-app purchases – this SDK will NOT protect against the circumvention of the related purchase logic. In such scenario this target will be covered just applying Quixxi Shield

Salient Features

Quixxi Licensing framework:
  1. is highly secure. The framework uses many salt libraries to prevent application from crackers and also to confuse them. All the methods used for license validation are encrypted
  2. automatically identifies upon app launch whether the user has a valid license bought from Google Play Store
  3. automatically identifies if the paid app has been downloaded and installed from other unofficial but recognized stores as Samsung Galaxy Apps
  4. displays to illegal users error messages preventing the app usage, embedding them into the app as native code [C code] and making them quite inescapable
  5. implements a customer conversion policy, prompting to illegal users a dialog to purchase the app, in order to keep the client and increase your revenue
  6. offers multi-level security to your apps through the integration of our Licensing APIs

Google Firebase setup

Our first target will be Google Firebase integration. The reason is that it will generate the Server Key needed for producing the Quixxi Licensing SDK to be integrated in your paid app. In order to proceed please:
  1. create a project in Firebase console following the procedure explained in the Android documentation New Firebase Project
  2. register the app in Google Firebase Google Firebase App Registration
  3. copy the “google-services.json” file into the project’s app module folder [typically “projectfolder/app/”], as described by Google google-services.json Integration
  4. select “build.gradle (Project)” and in the dependencies section please add:
    classpath ‘com.google.gms:google-services:4.2.0’
    Please always use the latest version the “google-services” dependency
  5. add the FCM dependencies to your “build.gradle (Module: app)” file, e.g.:
    implementation ‘com.google.firebase:firebase-core:16.0.1’
    implementation ‘com.google.firebase-messaging:17.3.4’
    Please always use the latest versions of these dependencies
  6. at the end of the same file – out of the dependencies – please add:
    apply plugin: ‘com.google.gms.google-services’
  7. at this point – before proceeding further – please run the app to check that everything is all right

Creating the Licensing SDK on Quixxi Portal

Now – with Firebase correctly configured – we can start compiling and integrating Quixxi Licensing SDK as follows:
  1. if you don’t have yet created the container for your app in Quixxi portal create one using the “Add New”button, otherwise go directly to point 3
  2. in the “Create your app”dialog give a name to your app and click “Continue”
  3. click on the app box related to your app, choose “Supervise”in the header tab and then “Package” in the left-side menu
  4. click “Add Platform”and choose Android as platform. Analytics framework in the “Select modules” section should already come preselected
  5. enter the package name used in Android Studio, the FCM Server Key, the Google License Key and click “Start Packaging”
    NOTE for FCM Server Key and Google License Key
    1. the FCM Server Key can be found in Firebase Console -> Your Project -> Project Settings -> Cloud Messaging Google Server Key.png
    2. the Google License key can be found in Google Play Console -> Your Project -> Development tools -> Services&APIs Google Licensing Key.png
  6. now Quixxi will produce a library containing both Analytics and Licensing Frameworks, notifying you once it gets completed
  7. click “Download Library” to get the library and you will receive a package which contains a module called “QuixxiLibrary.aar”
    IMPORTANT – each app must integrate a specific “QuixxiLibrary.aar” file. Please do NOT recycle the same aar file for different apps because in this case all the data related to these apps would be sent to the same app container

Steps to integrate Quixxi Licensing SDK into an Android app

After downloading the Licensing SDK for the app let’s see how to integrate it into the Android Studio project and have License verification and Illegal Users management
IMPORTANT – before proceeding further let’s clarify that in order to successfully implement Licensing you will need to integrate our Analytics SDK, as explained in the Analytics documentation. In this way you will be ready to handle your customers individually, as it is needed for Licensing purposes
  1. in Android Studio go to ”File” -> ”Project Structure…” -> click the ”+” in the top left corner -> “Import .JAR/.AAR Package” -> “Next” -> select “QuixxiLibrary.aar” -> “Finish”. Please double-check that this step was correctly performed controlling that the “settings.gradle” file of your app shows a line like the following or add it to fix this step:
    include ‘:app’, ‘:QuixxiLibrary’
  2. after importing the Quixxi Licensing SDK, click on “File” -> “Project Structure…” -> select “Dependencies” tab-> click the “+” in the top right corner -> “Module Dependency” -> select “:QuixxiLibrary”. Again, please double-check that this step too was correctly performed opening your ”build.gradle (Module: app)” file. You should already find the following line in the list of “dependencies”, else please add it:
    implementation project(‘:QuixxiLibrary’)

Initialising the Quixxi Licensing framework

  1. in order to enable the Licensing framework you first need to import the class for Licensing:
    import a.b.c.A;
    and then add the following lines of code in the onCreate(), onResume() and onPause() methods of your MainActivity
  2. in the onCreate() method please add:
    A lu = new A(_activity_context);
    lu.a(_activity_context);
  3. in the onResume() method please add:
    A a = A.ad(_activity_context);
    a.yu(_activity_context);
  4. in the onPause() method please add:
    A a = A.ad(_activity_context);
    a.p(_activity_context);
  5. after this let’s move to the “AndroidManifest.xml” file of your app to declare the messaging service. Further details can be found here
    <application
    
        <!-- … -->
    
        <service android:name=".MyFirebaseMessagingService" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
    
    </application>
    Your manifest now will look similar to: Android Licensing Manifest
  6. create a new class “MyFirebaseMessagingService” on the same level of your MainActivity copying and pasting the following code: Android Studio Firebase Messaging
    package com.myfirstproject.io;
    
    import com.google.firebase.messaging.RemoteMessage;
    import a.b.c.QuixxiFireBaseMessagingService;
    
    public class MyFirebaseMessagingService extends QuixxiFireBaseMessagingService{
        @Override
        public void onMessageReceived(RemoteMessage remoteMessage) {
            super.onMessageReceived(remoteMessage);
        }
    }
  7. finally let’s manually add the Firebase dependencies into your ”build.gradle (Module: app)” file, e.g.:
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
Done! Now until the moment in which the app purchase is not yet verified and the user has not yet been blocked [manually or automatically after grace period expiration] the Licensing SDK will try to verify the purchase and perform a license check against the Google PlayStore. If the user is legal he will be able to use the app while if the app is a pirated copy he will be stopped according to the modalities to be discussed in one of the upcoming sections

View users information in Quixxi Dashboard

Once your app has integrated both the Analytics and Licensing frameworks and is published on the PlayStore you can view the breakdown about the users of your apps on the Quixxi portal. You will find the statistics about the number of licensed users, unlicensed users and the number of users that you have blocked for the illegal installation of your app

How to block a user and blocking policies

You can prevent any user – legal or illegal – from using the app entering the Quixxi portal under “Supervise” -> “Users” [“Data” view in the top right corner] or “Illegal Users” -> “Block” from the dropdown menu at the end of the line. A message for blocking will be sent to the app and – after showing a block dialog – its further use is disabled

Android Licensing blocking illegal users

A user can be blocked according to three different policies that are shown and explained below:

Android Licensing settings
  1. “Immediately block after 7-day grace period” – with this blocking policy the user is given by default a grace period of one week which is the maximum time for the illegal user to become a regular user. In this timeframe the illegal user will be treated like a legal one. Such period might not necessarily be a courtesy but a good practice. If the transaction to buy the app takes time to be approved then a user who already paid could be seen as illegal only because the payment has not been processed. Thus – due to his temporary illegal status – he could not be able to use the app despite having paid for. In this scenario a grace period can help avoid bad reviews and complaints on PlayStore. Anyway after the grace period expiration the user will be immediately blocked
  2. “Manual block only” – it is the option where the developer is in charge of choosing what to do, without any grace period involved
  3. “Send a series of reminders before blocking (suggested)” – with this strategy you can reduce the grace period duration, schedule the messages to be sent to the illegal users and automatically block them straight after if they don’t buy the app

Push Notifications

The same dropdown menu has a “Message” feature that you can use to send push notifications to warn specific illegal customers about the License infringement or to all your userbase, for example to keep them updated [e.g. send a notification for a new promotion or a new functionality]

Android Licensing SDK – Quick Start Guide

Summary

Quixxi Licensing SDK is usable by enterprises and mobile app developers to protect the distribution of paid apps on Google Play Store, Samsung Galaxy Apps and Amazon Appstore. You can track and block the usage of your paid app whenever it is not the one provided by these recognized stores
IMPORTANT – this framework applies ONLY on paid apps, with or without in-app purchases. But if you have a freemium model – i.e. a free app whose revenue is based on in-app purchases – this SDK will NOT protect against the circumvention of the related purchase logic. In such scenario this target will be covered just applying Quixxi Shield

Salient Features

Quixxi Licensing framework:
  1. is highly secure. The framework uses many salt libraries to prevent application from crackers and also to confuse them. All the methods used for license validation are encrypted
  2. automatically identifies upon app launch whether the user has a valid license bought from Google Play Store
  3. automatically identifies if the paid app has been downloaded and installed from other unofficial but recognized stores as Samsung Galaxy Apps
  4. displays to illegal users error messages preventing the app usage, embedding them into the app as native code [C code] and making them quite inescapable
  5. implements a customer conversion policy, prompting to illegal users a dialog to purchase the app, in order to keep the client and increase your revenue
  6. offers multi-level security to your apps through the integration of our Licensing APIs

Google Firebase setup

Our first target will be Google Firebase integration. The reason is that it will generate the Server Key needed for producing the Quixxi Licensing SDK to be integrated in your paid app. In order to proceed please:
  1. create a project in Firebase console following the procedure explained in the Android documentation New Firebase Project
  2. register the app in Google Firebase Google Firebase App Registration
  3. copy the “google-services.json” file into the project’s app module folder [typically “projectfolder/app/”], as described by Google google-services.json Integration
  4. select “build.gradle (Project)” and in the dependencies section please add:
    classpath ‘com.google.gms:google-services:4.2.0’
    Please always use the latest version the “google-services” dependency
  5. add the FCM dependencies to your “build.gradle (Module: app)” file, e.g.:
    implementation ‘com.google.firebase:firebase-core:16.0.1’
    implementation ‘com.google.firebase-messaging:17.3.4’
    Please always use the latest versions of these dependencies
  6. at the end of the same file – out of the dependencies – please add:
    apply plugin: ‘com.google.gms.google-services’
  7. at this point – before proceeding further – please run the app to check that everything is all right

Creating the Licensing SDK on Quixxi Portal

Now – with Firebase correctly configured – we can start compiling and integrating Quixxi Licensing SDK as follows:
  1. if you don’t have yet created the container for your app in Quixxi portal create one using the “Add New”button, otherwise go directly to point 3
  2. in the “Create your app”dialog give a name to your app and click “Continue”
  3. click on the app box related to your app, choose “Supervise”in the header tab and then “Package” in the left-side menu
  4. click “Add Platform”and choose Android as platform. Analytics framework in the “Select modules” section should already come preselected
  5. enter the package name used in Android Studio, the FCM Server Key, the Google License Key and click “Start Packaging”
    NOTE for FCM Server Key and Google License Key
    1. the FCM Server Key can be found in Firebase Console -> Your Project -> Project Settings -> Cloud Messaging Google Server Key.png
    2. the Google License key can be found in Google Play Console -> Your Project -> Development tools -> Services&APIs Google Licensing Key.png
  6. now Quixxi will produce a library containing both Analytics and Licensing Frameworks, notifying you once it gets completed
  7. click “Download Library” to get the library and you will receive a package which contains a module called “QuixxiLibrary.aar”
    IMPORTANT – each app must integrate a specific “QuixxiLibrary.aar” file. Please do NOT recycle the same aar file for different apps because in this case all the data related to these apps would be sent to the same app container

Steps to integrate Quixxi Licensing SDK into an Android app

After downloading the Licensing SDK for the app let’s see how to integrate it into the Android Studio project and have License verification and Illegal Users management
IMPORTANT – before proceeding further let’s clarify that in order to successfully implement Licensing you will need to integrate our Analytics SDK, as explained in the Analytics documentation. In this way you will be ready to handle your customers individually, as it is needed for Licensing purposes
  1. in Android Studio go to ”File” -> ”Project Structure…” -> click the ”+” in the top left corner -> “Import .JAR/.AAR Package” -> “Next” -> select “QuixxiLibrary.aar” -> “Finish”. Please double-check that this step was correctly performed controlling that the “settings.gradle” file of your app shows a line like the following or add it to fix this step:
    include ‘:app’, ‘:QuixxiLibrary’
  2. after importing the Quixxi Licensing SDK, click on “File” -> “Project Structure…” -> select “Dependencies” tab-> click the “+” in the top right corner -> “Module Dependency” -> select “:QuixxiLibrary”. Again, please double-check that this step too was correctly performed opening your ”build.gradle (Module: app)” file. You should already find the following line in the list of “dependencies”, else please add it:
    implementation project(‘:QuixxiLibrary’)

Initialising the Quixxi Licensing framework

  1. in order to enable the Licensing framework you first need to import the class for Licensing:
    import a.b.c.A;
    and then add the following lines of code in the onCreate(), onResume() and onPause() methods of your MainActivity
  2. in the onCreate() method please add:
    A lu = new A(_activity_context);
    lu.a(_activity_context);
  3. in the onResume() method please add:
    A a = A.ad(_activity_context);
    a.yu(_activity_context);
  4. in the onPause() method please add:
    A a = A.ad(_activity_context);
    a.p(_activity_context);
  5. after this let’s move to the “AndroidManifest.xml” file of your app to declare the messaging service. Further details can be found here
    <application
    
        <!-- … -->
    
        <service android:name=".MyFirebaseMessagingService" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
    
    </application>
    Your manifest now will look similar to: Android Licensing Manifest
  6. create a new class “MyFirebaseMessagingService” on the same level of your MainActivity copying and pasting the following code: Android Studio Firebase Messaging
    package com.myfirstproject.io;
    
    import com.google.firebase.messaging.RemoteMessage;
    import a.b.c.QuixxiFireBaseMessagingService;
    
    public class MyFirebaseMessagingService extends QuixxiFireBaseMessagingService{
        @Override
        public void onMessageReceived(RemoteMessage remoteMessage) {
            super.onMessageReceived(remoteMessage);
        }
    }
  7. finally let’s manually add the Firebase dependencies into your ”build.gradle (Module: app)” file, e.g.:
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
Done! Now until the moment in which the app purchase is not yet verified and the user has not yet been blocked [manually or automatically after grace period expiration] the Licensing SDK will try to verify the purchase and perform a license check against the Google PlayStore. If the user is legal he will be able to use the app while if the app is a pirated copy he will be stopped according to the modalities to be discussed in one of the upcoming sections

View users information in Quixxi Dashboard

Once your app has integrated both the Analytics and Licensing frameworks and is published on the PlayStore you can view the breakdown about the users of your apps on the Quixxi portal. You will find the statistics about the number of licensed users, unlicensed users and the number of users that you have blocked for the illegal installation of your app

How to block a user and blocking policies

You can prevent any user – legal or illegal – from using the app entering the Quixxi portal under “Supervise” -> “Users” [“Data” view in the top right corner] or “Illegal Users” -> “Block” from the dropdown menu at the end of the line. A message for blocking will be sent to the app and – after showing a block dialog – its further use is disabled

Android Licensing blocking illegal users

A user can be blocked according to three different policies that are shown and explained below:

Android Licensing settings
  1. “Immediately block after 7-day grace period” – with this blocking policy the user is given by default a grace period of one week which is the maximum time for the illegal user to become a regular user. In this timeframe the illegal user will be treated like a legal one. Such period might not necessarily be a courtesy but a good practice. If the transaction to buy the app takes time to be approved then a user who already paid could be seen as illegal only because the payment has not been processed. Thus – due to his temporary illegal status – he could not be able to use the app despite having paid for. In this scenario a grace period can help avoid bad reviews and complaints on PlayStore. Anyway after the grace period expiration the user will be immediately blocked
  2. “Manual block only” – it is the option where the developer is in charge of choosing what to do, without any grace period involved
  3. “Send a series of reminders before blocking (suggested)” – with this strategy you can reduce the grace period duration, schedule the messages to be sent to the illegal users and automatically block them straight after if they don’t buy the app

Push Notifications

The same dropdown menu has a “Message” feature that you can use to send push notifications to warn specific illegal customers about the License infringement or to all your userbase, for example to keep them updated [e.g. send a notification for a new promotion or a new functionality]