Android OAID implementation in the SDK

 At a glance: Collect the Android OAID using the AppsFlyer SDK to attribute installs from third-party Android app stores.

Collecting OAIDs

The AppsFlyer SDK supports OAID collection using several methods. The method depends on the following factors: 

  • Device model and OS
  • AppsFlyer SDK version

Collection methods

To collect OAID, use the setCollectOaid method:

  • The AppsFlyer SDK collects the OAID from the device OS
  • For SDK V6.2.3+, the SDK will attempt to collect OAID, once the OAID dependencies are added to the app
  • For earlier SDK versions, the method needs to be called manually

Collect OAID (in China)

Select a collection method based on the SDK version. The developer must add the manufacturer's standalone JAR file to the app or add it to the AppsFlyer OAID SDK. 

  1. Download the MSA alliance SDK.
  2. Add OAID dependencies; they must support the manufacturer's standalone JAR file in the app-level build.gradle file:
    • implementation 'com.appsflyer:af-android-sdk:6.2.3@aar'
    • implementation 'com.appsflyer:oaid:6.2.4'
    • implementation files('libs/oaid_sdk_1.0.23.aar')

To collect the OAID in AppsFlyer SDK version V5.4.0+:

Once the OAID dependencies are added, OAID is collected automatically by default.

To collect the OAID in AppsFlyer SDK version V5.2.0 and V5.3.0:

Call setCollectOaid() before calling startTracking().

In the code, call AppsFlyerLib.getInstance().setCollectOaid(true);

Collect OAID (outside China)

When releasing an app outside China, The MSA SDK is not needed. Instead, use the Huawei OAID SDK to collect the device OAID.

1. Add the following to the project build.gradle file:

allprojects {
  repositories {
  // ...
    maven { url 'https://developer.huawei.com/repo/' }
mavenCentral() } }

For more information on "mavenCentral", please refer to our Android SDK developer documentation.

2. In the app-level build.gradle file, add the following dependencies (they must support the manufacturer's standalone JAR file):

implementation 'com.appsflyer:af-android-sdk:6.2.3@aar'
implementation 'com.appsflyer:oaid:6.2.4'
implementation 'com.huawei.hms:ads-identifier:3.4.39.302'

Notes:

  • The recommended com.huawei.hms:ads-identifier version is 3.4.39.302+
  • Make sure all OAID dependencies are properly added to the app-level build.gradle file before moving to the next step. 

3. To collect OAID according to the Android SDK version.

To collect the OAID in AppsFlyer SDK version V6.2.3 (best practice):

OAID is collected automatically by default.

To collect the OAID in AppsFlyer SDK version V5.4.0:

OAID is collected automatically by default when the version of 'com.huawei.hms:ads-identifier:3.4.39.302'is 3.4.39.302or below 3.4.30.300 (not included).

To collect the OAID in AppsFlyer SDK version V5.2.0 and V5.3.0:

Call setCollectOaid() before calling startTracking().

In the code, call AppsFlyerLib.getInstance().setCollectOaid(true);. And the version of 'com.huawei.hms:ads-identifier:3.4.39.302'should be 3.4.39.302or below 3.4.30.300 (not included).

Opting out of OAID

To opt-out of collecting the OAID:

Call setCollectOaid(false) before calling startTracking(). In the code call, 
AppsFlyerLib.getInstance().setCollectOaid(false);

Additional information

Supported devices

Supported devices

Use AppsFlyer SDK V5.1.0 and later with the AppsFlyer OAID module

Supported manufacturer versions
Huawei
  • EMUI: V9.0+
  • HMS: V2.62+
Xiaomi MIUI 10.2+
Vivo FuntouchOS 9+
OPPO Color OS 7.0+
Lenovo ZUI 11.4+
Samsung, Meizu, Nubia, ZTE, ASUS, OnePlus, Freeme OS, Ssui OS Android 10+
Was this article helpful?