Instalar SDK
Aprende a descargar e instalar el SDK de Android.
Antes de comenzar
Necesitas Android Studio para seguir estas guías.
Instalación del SDK para Android
Instala el SDK de Android con tu método preferido: a través de Gradle o manualmente.
Install using Gradle
Paso 1: Declarar repositorios
In the Project build.gradle
file, declare the mavenCentral
repository:
// ...
repositories {
mavenCentral()
}
/// ...
Paso 2: Agregar dependencias
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
- En Android Studio, cambia la estructura de carpetas de Android a Proyecto:
- Descarga el último SDK de Android y pégalo en tu proyecto de Android, en app > libs.
- Haz clic con el botón derecho en el
jar
que pegaste y selecciona Agregar como biblioteca. Cuando se te indique, haz clic en Refactorizar.Si se te solicita que te confirmes para git, haz clic en OK.
.
Cómo configurar los permisos necesarios
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.
Nota
- Si tu aplicación participa en el programa Diseñado para Familias:
- 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.- Para las aplicaciones que apuntan al nivel de API 32 (Android 12L) o anterior, este permiso no es necesario.
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" />
Revocación del permiso AD_ID
De acuerdo con la Política de Google, las aplicaciones dirigidas a niños no deben transmitir el ID de publicidad.
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"/>
Para obtener más información, consulta la documentación de Google Play Services.
Reglas de ProGuard
OPCIONAL
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:
Reglas de ProGuard del SDK de AppsFlyer
-keep class com.appsflyer.** { *; }
Agregar bibliotecas de referentes de tiendas
El SDK de AppsFlyer admite varias bibliotecas de referentes de tiendas. El uso de un referente de tienda mejora la precisión de la atribución.
Solo necesitas agregar la dependencia del referente, el SDK se encarga del resto.
Google Play Install Referrer
Add the following dependency to your build.gradle
:
dependencies {
// ...
implementation "com.android.installreferrer:installreferrer:2.2"
}
Reglas de ProGuard del referente de instalación de 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"
}
Reglas de ProGuard para referentes de la tienda Xiaomi GetApps
-keep public class com.miui.referrer.** {*;}
Nota
Huawei and Samsung store referrers are supported out-of-the-box starting SDK
V6.1.1
and do not require any additional integration.
Problemas conocidos
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.
Verifica que tienes los archivos necesarios abriendo tu APK en Android Studio:
Si faltan esos archivos, el SDK no puede realizar solicitudes de red a nuestro servidor, y deberás comunicarte con tu CSM o con el soporte.
Actualizado hace 23 días