Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”

An overview of the

The AppsFlyer Android SDK provides installation and event logging for Android apps. The SDK can be used with Java/Kotlin.

Embed the SDK in your application to document:

  • The application installation
  • User interactions (for example, sessions and in-app events)

AppsFlyer: Android-SDK integration

Compatibility between SDK and Android platform

  • 1. Android 4.0 or above
  • 2. Non-mobile Android platforms such as smart TVS, including Amazon’s Fire TV
  • 3. Out-of-store markets for Android apps, such as Amazon and Baidu

Add the SDK to the project

1. Add the SDK using Gradle (recommended)

  • Module-level /app/build.gradle before dependencies:
repositories { 
    mavenCentral()
}
Copy the code
  • Add the latest version of AppsFlyerSDK as a dependency
Dependencies {implementation 'com.appsFlyer :af-android-sdk:6.3.2'}Copy the code

2. Manually add the SDK

  • Download the AF – Android – SDK. The jar

  • Add it to the project

  • Add the following permissions to AndroidMainfest:

com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE
Copy the code

The 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" />
<receiver
    android:name="com.appsflyer.SingleInstallBroadcastReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>
Copy the code

Implement and initialize the SDK

1. Get your development key

  • Go to the application’s information center.

  • In the upper right corner of an app, click… Select configuration Click Apply Configuration.

  • I found your development key.

There is only one application development key for the same account, no matter how many applications are created under the same account.

2. Initialize the SDK

import com.appsflyer.AppsFlyerConversionListener;
import com.appsflyer.AppsFlyerLib;
/** * Creator: SCC * Function description: AppsFlyer access */
public class MyApp extends Application {
    private static MyApp singleton;

    @Override
    public void onCreate(a) {
        super.onCreate();
        AppsFlyerConversionListener conversionListener = new AppsFlyerConversionListener() {
            @Override
            public void onConversionDataSuccess(Map<String, Object> conversionData) {
                for (String attrName : conversionData.keySet()) {
                    MLog.e("attribute: " + attrName + "="+ conversionData.get(attrName)); }}@Override
            public void onConversionDataFail(String errorMessage) {
                MLog.e( "error getting conversion data: " + errorMessage);
            }
            @Override
            public void onAppOpenAttribution(Map<String, String> conversionData) {
                for (String attrName : conversionData.keySet()) {
                    MLog.e("attribute: " + attrName + "="+ conversionData.get(attrName)); }}@Override
            public void onAttributionFailure(String errorMessage) {
                MLog.e("error onAttributionFailure : "+ errorMessage); }}; AppsFlyerLib.getInstance().init("Your development key.", conversionListener, getApplicationContext());
        AppsFlyerLib.getInstance().start(this); }}Copy the code

To add an app, go directly to the image above

Setting Application Information

  • Google Play
    • Has been on
    • To be approved/not published
  • Third-party store

There’s nothing to be said for Google to fill in the package name.

Third-party store

Keep the channel name consistent when you set up AndroidMainfest.xml.


      
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.scc.demo">.<application>.<meta-data
            android:name="CHANNEL"
            android:value="shanghai" />
    </application>

</manifest>
Copy the code

Set the time zone and currency

That’s it. How to test the back open whole. The same with iOS, you just get started.

Few words said: registration link for you: hq1.appsflyer.com/auth/login.