Installer le SDK

Découvrez comment télécharger et installer le SDK Android.

Avant de commencer

Vous avez besoin de Android Studio pour suivre ces guides.

Installation du SDK Android

Pour installer le SDK Android, vous pouvez utliser l'une des méthodes suivantes : via Gradle ou manuellement.

Install using Gradle

Recommandé

Étape 1 : déclarer les référentiels
In the Project build.gradle file, declare the mavenCentral repository:

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

Étape 2 : ajoutez les dépendances
In the application build.gradle file, add the latest Android SDK package:

dependencies {
    // Get the latest version from https://mvnrepository.com/artifact/com.appsflyer/af-android-sdk
    implementation 'com.appsflyer:af-android-sdk:<<HERE_LATEST_VERSION>>'
    // For example
    // implementation 'com.appsflyer:af-android-sdk:6.12.1>> 
}

Manual install

  1. Dans Android Studio, basculez la structure de dossiers d'Android à Projet :
  2. Téléchargez le dernier SDK Android et collez-le dans votre projet Android, sous app > libs.
  3. Faites un clic droit sur l'élément jar que vous avez collé et sélectionnez Ajouter en tant que bibliothèque. Lorsque vous y êtes invité, cliquez sur Refactoriser.

    Si vous êtes invité dans git, cliquez sur OK.

    .

Définir les autorisations requises

Add the following permissions to AndroidManifest.xml in the manifest section:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package=YOUR_PACKAGE_NAME>

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

      ...

</manifest>

The AD_ID permission

In early 2022, Google announced a change to the behavior of Google Play Services and fetching of the Android Advertising ID. According to the announcement, apps targeting Android 13 (API 33) and above must declare a Google Play services normal permission in their AndroidManifest.xml file in order to get access to the device’s Advertising ID.

Starting V6.8.0, the SDK adds the AD_ID permission automatically.

📘

Remarque

  • Si votre app participe au programme Designed for Families (conçu pour les familles) :
    • If using SDK V6.8.0 and above, you should Revoke the AD_ID permission.
    • If using SDK older than V6.8.0, don't add this permission to your app.
  • Cette autorisation n'est pas nécessaire pour les apps qui ciblent les API de niveau 32 et - (Android 12L).

Apps that use SDK versions older than V6.8.0 and target Android 13 (API 33) and above must manually include the permission in their AndroidManifest.xml to have access to the Advertising ID:

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

Révoquer l’autorisation AD_ID

La politique de Google, stipule que toute app ciblant les enfants ne doit pas transmettre l’identifiant publicitaire.

When using SDK V6.8.0 and above, children apps targeting Android 13 (API 33) and above must prevent the permission from getting merged into their app by adding a revoke declaration to their Manifest:

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

Pour plus d'informations, consultez la documentation de Google Play Services.

Règles ProGuard

OPTIONNELLE
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:

Règles ProGuard du SDK AppsFlyer

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

Ajouter des bibliothèques de référents de store

Le SDK AppsFlyer prend en charge différentes bibliothèques de référents de store. Utiliser un référent de store augmente la précision de l’attribution.

Il vous suffit d'ajouter la dépendance du référent et le SDK s'occupe du reste.

Google Play Install Referrer

Add the following dependency to your build.gradle:

dependencies {
    // ...
    implementation "com.android.installreferrer:installreferrer:2.2"
}

Règles ProGuard de référent d'installation Google Play

-keep public class com.android.installreferrer.** { *; }

Xiaomi GetApps store referrer

V6.9.0
Add the following dependency to your build.gradle:

dependencies {
  // ...
  implementation "com.miui.referrer:homereferrer:1.0.0.6"
}

Règles ProGuard des référents de store Xiaomi GetApps

-keep public class com.miui.referrer.** {*;}

📘

Remarque

Huawei and Samsung store referrers are supported out-of-the-box starting SDK V6.1.1 and do not require any additional integration.

Problèmes connus

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 application@fullBackupContent 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.

Vérifiez que vous disposez des fichiers requis en ouvrant votre APK dans Android Studio.

En cas d'absence de ces fichiers, le SDK ne pourra pas lancer de requête réseau à notre serveur, et il vous faudra contacter votre CSM ou le centre d'assistance.