Skip to main content
This guide will help you install and set up the Linkrunner SDK in your native Android application.

Requirements

  • Android 5.0 (API level 21) or higher
  • Android Studio Flamingo (2022.2.1) or newer
  • Gradle 8.0+

Installation

Gradle (build.gradle)

Add the Linkrunner SDK to your app’s build.gradle file:
dependencies {
    implementation 'io.linkrunner:android-sdk:2.1.5'
}
Make sure you have the Maven Central repository in your project’s settings.gradle file:
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}

Required Permissions

Add the following permissions to your AndroidManifest.xml file:
<!-- Required for the SDK to make network requests -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Note: The AD_ID permission (<uses-permission android:name="com.google.android.gms.permission.AD_ID" />) is already included in the SDK and is required for collecting device identifiers (GAID).

Backup Configuration

The SDK provides backup rules to exclude Shared Preferences data from backup. This prevents the retention of the Linkrunner install ID during reinstallation, ensuring accurate detection of new installs and re-installs.
This backup configuration works similarly for all SDKs (React Native, Flutter, and native Android). The same Android backup rules apply regardless of which SDK you’re using.

Adding Backup Rules to Your App

Add to your AndroidManifest.xml:
<application
    android:fullBackupContent="@xml/linkrunner_backup_descriptor"
    android:dataExtractionRules="@xml/linkrunner_backup_rules">
    <!-- Your app content -->
</application>
  • android:fullBackupContent - Used for Android 6-11
  • android:dataExtractionRules - Used for Android 12+

Merging Backup Rules

If you already have your own backup rules specified (e.g., android:fullBackupContent="@xml/my_backup_descriptor" or android:dataExtractionRules="@xml/my_rules"), then manually add the following rules to your existing files: For legacy backup (Android 6-11) in res/xml/my_backup_descriptor:
<full-backup-content>
    <!-- Exclude LinkRunner SDK SharedPreferences from legacy backup -->
    <exclude domain="sharedpref" path="io.linkrunner.sdk_prefs"/>
</full-backup-content>
For modern backup (Android 12+) in res/xml/my_backup_rules.xml:
<data-extraction-rules>
    <cloud-backup>
        <!-- Exclude LinkRunner SDK SharedPreferences from cloud backup -->
        <exclude domain="sharedpref" path="io.linkrunner.sdk_prefs"/>
    </cloud-backup>
    <device-transfer>
        <!-- Exclude LinkRunner SDK SharedPreferences from device transfer -->
        <exclude domain="sharedpref" path="io.linkrunner.sdk_prefs"/>
    </device-transfer>
</data-extraction-rules>

Importing in Kotlin/Java

After installation, you can import the SDK in your Kotlin or Java files:
// Kotlin
import io.linkrunner.sdk.LinkRunner
// Java
import io.linkrunner.sdk.LinkRunner;
I