Follow these steps to have a basic integration of the app's miles® SDK in your Android application.

Android Quickstart

Estimated time: 20 minutes

This guide will go over:

  • Conditions and minimum requirements

  • Installation

  • Configuration

  • Initialization

  • Attaching

Conditions and minimum requirements

Minimum Android version: 4.1 (API 16)

This guide was written under the assumption that you use Android Studio

I. Installation

Add the following lines to your top-level build.gradlefile.

//You can set login and password in env variables
def mavenAppsmilesUsername = System.getenv("APPSMILES_ARTIFACTORY_LOGIN") ?: ''
def mavenAppsmilesPassword = System.getenv("APPSMILES_ARTIFACTORY_PASSWORD") ?: ''
//Or in local.properties
def folder = new File( 'local.properties' )
if( folder.exists() ) {
mavenAppsmilesUsername = properties.getProperty("maven_appsmiles.username") ?: mavenAppsmilesUsername
mavenAppsmilesPassword = properties.getProperty("maven_appsmiles.password") ?: mavenAppsmilesPassword
allprojects {
repositories {
maven {
url 'https://artifactory.appsmiles.eu/artifactory/list/appsmiles/'
credentials {
username = mavenAppsmilesUsername
password = mavenAppsmilesPassword

https://artifactory.appsmiles.eu/artifactory/list/appsmiles is a private repository, you need a login and a password Set the login and password in the file local.properties of your project Contact us to get a login and password

And these to your app's build.gradle file

dependencies {
implementation 'com.moonmiles.apm:apm:5.1.0'

The weight of an android application containing our SDK will approximately increase by 2.5 MB

Android dependencies

Our SDK uses the dependencies appcompat, recyclerview and lottie to work. You can overwrite them in your module's build.gradle:

dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.airbnb.android:lottie:3.0.7'

For more information about appcompat-v7 and recyclerview-v7, click here For more information about lottie, click here

Security dependencies (TLS 1.2 for Android 4.1 – 4.4)

For security reasons, our server only supports HTTPS connection with TLS 1.2 protocol. However, Android 4.1 – 4.4 phones don't use TLS 1.2 out-of-the-box, and need the help of Google Play Services.

In order to fix this, we need the play-services-base library. It is already included in all of the play-services-* libraries, so:

implementation 'com.google.android.gms:play-services-base:16.1.0'

More informations here : https://developer.android.com/training/articles/security-gms-provider.html

II. Configuration

Set (1) the permissions, (2) the partnerId and the partnerSecret in your AndroidManifest.xml

<manifest ...>
<!-- (1) Permissions -->
<!-- required -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- optional -->
<uses-permission android:name="android.permission.VIBRATE"/>
<application ...>
<!-- (2) app's miles partnerId and partnerSecret -->
<meta-data android:name="com.moonmiles.partnerID" android:value="@string/ConfigPartnerID" />
<meta-data android:name="com.moonmiles.partnerSecret" android:value="@string/ConfigPartnerSecret" />

Add the following lines for ProGuard

# app's miles
-keep class com.moonmiles.** { *; }
-keep interface com.moonmiles.** { *; }

III. Initialization

In YourAppApplication.java, in the method onCreate(), retrieve an instance of APM and set the baseUrl of our API.







APM apm = APMPublic.sharedInstance(this); //this == Context

We host projects on multiple servers, double check with us or your team to verify the base URL.

IV. Attaching

For this last step, you must attach our SDK to your main or abstract Activity/Fragment.

Attaching to an « Activity »

Add the following methods in your GlobalActivity

  • APMPublic.sharedInstance(this).onCreate(savedInstanceState, getIntent());

  • APMPublic.sharedInstance(this).onResume(this, getIntent());

  • APMPublic.sharedInstance(this).onNewIntent(intent);

  • APMPublic.sharedInstance(this).onPause();

  • APMPublic.sharedInstance(this).onActivityResult(requestCode, resultCode, data);

protected void onCreate(Bundle savedInstanceState)
APMPublic.sharedInstance(this).onCreate(savedInstanceState, getIntent());
protected void onResume()
APMPublic.sharedInstance(this).onResume(this, getIntent());
protected void onNewIntent(Intent intent)
protected void onPause()
protected void onActivityResult(int requestCode, int resultCode, Intent data)
super.onActivityResult(requestCode, resultCode, data);
APMPublic.sharedInstance(this).onActivityResult(requestCode, resultCode, data);

Attaching to a « Fragment »

If your application uses Fragments to show entire screens, add the following method to the appropriate fragments or their Abstract class:

public void onResume()
Activity activity = getActivity();
APMPublic.sharedInstance(activity).onResume(activity, null);

You're done with the installation !

You should be able to see our SDK on your application.

And the banner appear !

Head to the next section to start integrating our SDK into your app's features.