Install SDK

Learn how to download and install the Android SDK.

Before you begin

You need Android Studio to follow along with these guides.

Installing the Android SDK

Install the Android SDK using your preferred method: Via Gradle, or manually.

Install using Gradle

Recommended

Step 1: Declare repositories
In the Project build.gradle file, declare the mavenCentral repository:

// ...
repositories {
   mavenCentral()
}
/// ...

Step 2: Add dependencies
In the application build.gradle file, add the latest Android SDK package:

dependencies {
    implementation 'com.appsflyer:af-android-sdk:6.3.2'
}

Manual install

  1. In Android Studio, switch the folder structure from Android to Project:
  2. Download the latest Android SDK and paste it in your Android project, under app > libs.
  3. Right-click the jar you pasted and select Add As Library. When prompted, click Refactor. If prompted to commit to git, click OK.

Setting required permissions

Add the following permissions to AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

Adding the Google Play Install Referrer

Optional Recommended
To improve attribution accuracy, it's recommended to install the Google Play Install Referrer.

ProGuard rules

Optional
If you are using ProGuard and you encounter a warning regarding our AFKeystoreWrapper class, then add the following code to your proguard-rules.pro file:

-keep class com.appsflyer.** { *; }

Known issues

Backup rules

If you add android:fullBackupContent="true" inside the tag in the AndroidManifest.xml, you might get the following error:

Manifest merger failed : Attribute [email protected] value=(true)

To fix this error, add tools:replace="android:fullBackupContent" in the <application> tag in the AndroidManifest.xml file.

If you have your own backup rules specified (android:fullBackupContent="@xml/my_rules"), in addition to the instructions above, please merge them with AppsFlyer rules manually by adding the following rule:

<full-backup-content>
    ...//your custom rules
    <exclude domain="sharedpref" path="appsflyer-data"/>
</full-backup-content>

Missing resource files

SDK V5
If you are using Android SDK V5 and above, make sure that in the APK file, in addition to the classes.dex and resources files, you also have a com > appsflyer > internal folder with files a- and b- inside.
Note: Before SDK 5.3.0, file names are a. and b.

Check that you have the required files by opening your APK in Android Studio:

If those files are missing, the SDK can't make network requests to our server, and you need to contact your CSM or support.

Updated 15 days ago



Install SDK


Learn how to download and install the Android SDK.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.