Android OAID implementation in the SDK

At a glance:  Collecting the OAID device identifier in the AppsFlyer SDK

Collecting OAIDs

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

  • Device model  and OS the model
  • AppsFlyer SDK version

The methods include setCollectOaid and setOaidData.

Collection methods

The methods include setCollectOaid and setOaidData. 

  • setCollectOaid:
    • For all devices, the AppsFlyer SDK collects the OAID directly from the device OS. 
    • From SDK V5.4.0, the SDK will attempt to collect OAID automatically by default.
    • For earlier SDK versions, the method needs to be set manually.
  • setOaidData: For when the developer wants to use AIDL to collect the OAID, and then pass the OAID to the AppsFlyer SDK.

setOaidData (AIDL)—developer passes the OAID

To collect the OAID in Huawei devices using AppsFlyer SDK version V5.2.0 and later: 

  1. Follow Huawei instructions source 1 or source 2 to collect OAID via AIDL.
  2. Pass the OAID collected by Huawei to the AppsFlyer SDK.
  3. Call setOaidData() before calling startTracking(). In the code call, 


This example demonstrates the setOaidData (AIDL) method for Huawei devices:

  1. Create a folder, aidl.
  2. In the aidl folder, create a package with this exact name, com.uodis.opendevice.aidl.
  3. Create an .aidl file, OpenDeviceIdentifierServiced.

  4. Check that file OpenDeviceIdentifierServiced includes this code:

            package com.uodis.opendevice.aidl;
      * Important: Do not modify the method sequence of the AIDL file.!!!
     interface OpenDeviceIdentifierService { 
        String getOaid(); 
        boolean isOaidTrackLimited();
  5. Create a class that fetches the OAID and passes it to the AppsFlyer SDK. 
    In this example, the class is OaidFetcher.

    public class OaidFetcher {
        public static void connect(Context context) {
            ServiceConnection connection = new ServiceConnection() {
                public void onServiceConnected(ComponentName name, IBinder service) {
                    OpenDeviceIdentifierService oaidService = OpenDeviceIdentifierService.Stub.asInterface(service);
                    try {
                        String oaid = oaidService.getOaid();
                    } catch (RemoteException e) {
                public void onServiceDisconnected(ComponentName name) {
            Intent bindIntent = new Intent("com.uodis.opendevice.OPENIDS_SERVICE");
            context.bindService(bindIntent, connection, context.BIND_AUTO_CREATE);

setCollectOaid—collect the OAID from the device OS

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 AAR provided by the MSA alliance to your module libs folder
  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:5.4.3@aar'
    • implementation 'com.appsflyer:oaid:6.1.1'
    • implementation files('libs/oaid_sdk_1.0.23.aar')

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

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);

To opt-out of collecting the OAID:

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

Additional information

Supported devices

Supported devices

Use AppsFLyer SKD V5.1.0 and later with the AppsFlyer OAID module

Supported manufacturer versions
  • EMUI: V9.0 and later
  • HMS: V2.62 and later
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?