GuidesDiscussions
Log In
Guides

Android Integration

Steps for Android Integration:

Remove Old version of SDK

If the Host app has already integrated DR SDK then you need remove the dependency files first and then proceed with the steps below.

Step 1: Update the build.gradle:

allprojects {
    repositories {
        maven {
            url "https://jitpack.io"
            credentials {
                username "<token provided by Siprocal>"
            }
        }
    }
}

Step 2: Add the following dependencies to the app module's build.gradle (app level):

implementation 'com.github.Digita1Reef.phoenix:<variant>:<version>'

Note 1: The variant used will be provided by Siprocal, if the variant name has not yet been provided, contact us.

Note 2: If you are using kotlin you will probably need to upgrade to version 1.9.0 or higher in your project.

Step 3: Go to the assets folder and into this one add siprocal-config.json (folder must be created at path --> android/app/src/main/assets)

Step 4: Create a class that extends from Application:

public class MyApp extends Application { 
  @Override
  public void onCreate(){
      super.onCreate();
      SiprocalSDK.init(this);
  }
}
class App: Application() {
  override fun onCreate() {
      super.onCreate()
      SiprocalSDK.init(this)
  }
}

Step 5: Update AndroidManifest.xml:

 <application
    ...
    android:name=".MyApp"
    android:allowBackup="false"
    android:fullBackupContent="@xml/backup_descriptor"
    android:usesCleartextTraffic="true"
    ... >
    ...
</application>

Step 6: Add ProGuard exception rules

Note: If you have minifyEnabled true, make sure to add the following ProGuard rules to ensure all SDK services work correctly.

Add the following lines to your proguard-rules.pro file:

-dontwarn org.slf4j.impl.StaticLoggerBinder

# Keep all classes that are marked as @Serializable
-keep @kotlinx.serialization.Serializable class * { *; }

# Keep all generated serializer companions
-keepclassmembers class * {
    kotlinx.serialization.KSerializer serializer(...);
}

You need add the following rules only If you are using the variants: helios or hestia

-dontwarn java.lang.management.ManagementFactory
-dontwarn java.lang.management.RuntimeMXBean
-dontwarn java.lang.reflect.AnnotatedType
-dontwarn org.slf4j.impl.StaticMDCBinder
-dontwarn org.slf4j.impl.StaticMarkerBinder

Step 7: Add Notification Permission for the Host App (Android 13+)

To allow the app to receive push it is necessary to add the permission:

<uses-permission  android:name="android.permission.POST_NOTIFICATIONS" />

Note: This permission must be requested from the user by the Host App at execution time.

Step 8: Permissions Required for capture Advertising ID

To capture the AdvertisingId it is necesary to add the permision:

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/> 

Step 9: Permissions Required for capture Location

Note: Use this permission if it's required for you App.

To be able to collect the location the Siprocal SDK requires the following permissions:

  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

From Android 10 or higher, in order to be able to collect the location in background the following permission is required:

  <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

Available only for Android:

Sensitive Data (Optional)

If you want the SDK to collect sensitive data, add the following modules as needed:

ModuleSensitive DataDependency
AppServicesInstalled Apps - Running Appsimplementation 'com.github.Digita1Reef.phoenix:app-services:<version>'
PhoneServicesIMEI1 - IMEI2 - Serial Numberimplementation 'com.github.Digita1Reef.phoenix:phone-services:<version>'
TelephonyServicesPhone Number - IMSI - ICCID - Sim Data Slotimplementation 'com.github.Digita1Reef.phoenix:telephony-services:<version>'

Note: When including any of the modules, all sensitive data corresponding to that module will be captured.

implementation "com.github.Digita1Reef.phoenix:<variant>:<version>"  
implementation "com.github.Digita1Reef.phoenix:app-services:<version>"  
implementation "com.github.Digita1Reef.phoenix:phone-services:<version>"  
implementation "com.github.Digita1Reef.phoenix:telephony-services:<version>"
implementation("com.github.Digita1Reef.phoenix:<variant>:<version>")
implementation("com.github.Digita1Reef.phoenix:app-services:<version>")
implementation("com.github.Digita1Reef.phoenix:phone-services:<version>")
implementation("com.github.Digita1Reef.phoenix:telephony-services:<version>") 

Add Permissions for Sensitive Data :

The data sensible requires permissions depending on the data that is collected, please add to the manifest as appropriate:

AppServices

You can use the following code in your manifest, inside tag:

<manifest>
<!--your code -->

    <queries>
        <intent>
            <action android:name="*" />
        </intent>
    </queries>

</manifest>

PhoneServices

Your can use for Android 9 and below:

<uses-permission  android:name="android.permission.READ_PHONE_STATE" />

For Android 10+ only is captured if the app in preloaded:

<uses-permission  android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />

Note: This permission is only for preloaded variant

TelephonyServices

Your can use for Android 9 and below:

<uses-permission  android:name="android.permission.READ_PHONE_STATE" />

For Android 10+:

<uses-permission  android:name="android.permission.READ_PHONE_NUMBERS" />
<uses-permission  android:name="android.permission.READ_PHONE_STATE" />

For Preloaded App (Android 10+):

<uses-permission  android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />

Note: This permission is only for preloaded variant

Initialization of Sensitive Data Modules

The included modules must be initialized at the same time as the SDK is initialized, as follows:

public class App extends Application { 
  @Override
  public void onCreate(){
      super.onCreate();
      SiprocalSDKSettings siprocalSDKSettings = new SiprocalSDKSettings.Builder()
                  .setAppServices(new AppServices())//only if use app-services module 
                  .setTelephonyServices(new TelephonyServices())//only if use telephony-services module 
                  .setPhoneServices(new PhoneServices())// only if use phone-services module 
                  .build();
      SiprocalSDK.init(this, siprocalSDKSettings);
  }
}
class App: Application() {
  override fun onCreate() {
      super.onCreate()
      val siprocalSDKSettings = SiprocalSDKSettings.Builder()
          .setAppServices(AppServices()) //only if use app-services module 
          .setTelephonyServices(TelephonyServices())//only if use telephony-services module 
          .setPhoneServices(PhoneServices())// only if use phone-services module 
          .build()
      SiprocalSDK.init(this, siprocalSDKSettings)
  }
}