> ## Documentation Index
> Fetch the complete documentation index at: https://help.airbridge.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting - Android SDK (Deprecated)

<AccordionGroup>
  <Accordion title="BillingClient Dependency">
    If you install the Airbridge SDK manually, you may encounter a compilation error due to a `BillingClient` dependency issue.

    Starting from Airbridge SDK 2.26.1, a feature for collecting In-App purchase history has been added. To accommodate this, the SDK sets the In-App purchase library dependency as `compileOnly`, which does not cause issues during Gradle builds. However, when installed manually, a missing dependency may lead to compilation errors.

    To resolve this issue, please refer to the following instructions.

    ```groovy lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
    dependencies {
        api fileTree(dir: 'libs', include: ['billingClient.aar'])
    }
    ```
  </Accordion>

  <Accordion title="Ad ID permission">
    GAID is being collected as 00000000-0000-0000-0000-000000000000 even though LAT (Limited Ad Tracking) is deactivated.

    1. Open the AndroidManifest.xml file.
    2. Follow the method below to add the `com.google.android.gms.permission.AD_ID` permission.

    ```xml lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
    <manifest ...>
      ...
      <uses-permission android:name="com.google.android.gms.permission.AD_ID" />
      ...
    </manifest>
    ```

    For more details, refer to the [Google Play Services document](https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#public-string-getid).
  </Accordion>

  <Accordion title="Braze push notification">
    Deeplink Open events that occur through the push notifications generated by the Braze SDK are not collected by Airbridge. Instead, the App Open event is collected.

    The Airbridge Android SDK uses the `dataString` in the `action` and `intent` of the `Activity` to distinguish between Deeplink Open events and App Open events.

    When a user opens the app through a push notification using the Braze SDK, the app goes through an activity called `NotificationTrampolineActivity`. This activity handles push notifications, but the `dataString` is not included in its `action` and `intent`, preventing the SDK from determining if it's a Deeplink Open event or an App Open event.

    The problem can be solved using the code snippet below for Airbridge Android SDK versions v2.21.5 and later.

    <CodeGroup>
      ```java Java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      AirbridgeConfig config = new AirbridgeConfig.Builder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
          .setLifecycleIntegration(new AirbridgeLifecycleIntegration() {
          @Nullable
          @Override
          public String getDataString(@NotNull Activity activity) {
            if (activity.getClass().getName().equals("com.braze.push.NotificationTrampolineActivity")
                && activity.getIntent() != null
                && activity.getIntent().getExtras() != null) {
              return activity.getIntent().getExtras().getString("uri");
            }
            return null;
          }
        })
          .build();
      Airbridge.init(this, config)
      ```

      ```kotlin Kotlin lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      val config = AirbridgeConfig.Builder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
          .setLifecycleIntegration {
            it.takeIf { it.javaClass.name == "com.braze.push.NotificationTrampolineActivity" }
            ?.run { intent?.extras?.getString("uri") }
        }
          .build()
      Airbridge.init(this, config)
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="`deeplink.page`">
    Although the `deeplink.page` has been deprecated in the Airbridge Android SDK v.2.21.1, for Airbridge Android SDK v2.21.0 or earlier, you can set up the `intent-filter` by following the steps below.

    1. Open the `AndroidManifest.xml` file.
    2. Add the following `intent-filter` to the `activity` that will process deep links.

    ```xml lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
    <activity ...>
        ...
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="http" android:host="YOUR_APP_NAME.deeplink.page" />
            <data android:scheme="https" android:host="YOUR_APP_NAME.deeplink.page" />
        </intent-filter>
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="http" android:host="YOUR_APP_NAME.airbridge.io" />
            <data android:scheme="https" android:host="YOUR_APP_NAME.airbridge.io" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="YOUR_APP_URI_SCHEME" />
        </intent-filter>
    </activity>
    ```
  </Accordion>

  <Accordion title="Dependencies">
    #### `java.lang.NoClassDefFoundError: kotlin/coroutines/AbstractCoroutineContextKey` Error

    ```xml lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
    <activity ...>
        ...
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="http" android:host="YOUR_APP_NAME.deeplink.page" />
            <data android:scheme="https" android:host="YOUR_APP_NAME.deeplink.page" />
        </intent-filter>
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="http" android:host="YOUR_APP_NAME.airbridge.io" />
            <data android:scheme="https" android:host="YOUR_APP_NAME.airbridge.io" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="YOUR_APP_URI_SCHEME" />
        </intent-filter>
    </activity>
    ```

    * Reference: [https://github.com/Kotlin/kotlinx.coroutines/issues/1879](https://github.com/Kotlin/kotlinx.coroutines/issues/1879)

    According to [@qwwdfsad](https://github.com/Kotlin/kotlinx.coroutines/issues/1913#issuecomment-612916683), the use of kotlin-stdlib library v.1.3.70 and later is enforced when using kotlinx-coroutines-core library v1.3.5 and later.

    Make sure that you use kotlin-stdlib library v1.3.70 and later if you're using kotlinx-coroutines-core library v.1.3.5 and later through the `gradlew dependencies` command.
  </Accordion>

  <Accordion title="Auto Backup">
    * Reference - [https://developer.android.com/guide/topics/data/autobackup](https://developer.android.com/guide/topics/data/autobackup)

    The Airbridge SDK's `AndroidManifest.xml` includes rules to opt out of backing up the Shared Preferences data. This is done to prevent keeping the same Airbridge settings during reinstallation, ensuring that new installations or reinstalls can be detected accurately.

    To merge the Airbridge SDK backup rules with your app backup rules and prevent conflicts, refer to the following instructions.

    Below are the opt-out rules defined in the Airbridge SDK.

    <CodeGroup>
      ```xml Backup on Android 12 or later lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      <?xml version="1.0" encoding="utf-8"?>
      <data-extraction-rules>
          <cloud-backup>
              <exclude domain="sharedpref" path="airbridge-internal" />
              <exclude domain="sharedpref" path="airbridge-install" />
              <exclude domain="sharedpref" path="airbridge-user-info" />
              <exclude domain="sharedpref" path="airbridge-user-alias" />
              <exclude domain="sharedpref" path="airbridge-user-attributes" />
              <exclude domain="sharedpref" path="airbridge-device-alias" />
              <exclude domain="database" path="airbridge.db" />
          </cloud-backup>
          <device-transfer>
              <exclude domain="sharedpref" path="airbridge-internal" />
              <exclude domain="sharedpref" path="airbridge-install" />
              <exclude domain="sharedpref" path="airbridge-user-info" />
              <exclude domain="sharedpref" path="airbridge-user-alias" />
              <exclude domain="sharedpref" path="airbridge-user-attributes" />
              <exclude domain="sharedpref" path="airbridge-device-alias" />
              <exclude domain="database" path="airbridge.db" />
          </device-transfer>
      </data-extraction-rules>
      ```

      ```xml Backup on Android 11 and earlier lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      <?xml version="1.0" encoding="utf-8"?>
      <full-backup-content>
          <exclude domain="sharedpref" path="airbridge-internal" />
          <exclude domain="sharedpref" path="airbridge-install" />
          <exclude domain="sharedpref" path="airbridge-user-info" />
          <exclude domain="sharedpref" path="airbridge-user-alias" />
          <exclude domain="sharedpref" path="airbridge-user-attributes" />
          <exclude domain="sharedpref" path="airbridge-device-alias" />
          <exclude domain="database" path="airbridge.db" />
      </full-backup-content>
      ```
    </CodeGroup>

    <AccordionGroup>
      <Accordion title="Fix confilict with fullBackupContent=&#x22;string&#x22;">
        If you add `android:fullBackupContent="string"` in the `AndroidManifest.xml`, you might get the following error:

        ```html Build Output lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
        Manifest merger failed : Attribute application@fullBackupContent value=(string) from AndroidManifest.xml
        ```

        To fix this error, add `tools:replace="android:fullBackupContent"` in the `<application>` tag in the `AndroidManifest.xml` file.
      </Accordion>

      <Accordion title="Fix conflict with dataExtractionRules=&#x22;string resource&#x22;">
        If you add `android:dataExtractionRules="string resource"` in the `AndroidManifest.xml`, you might get the following error:

        ```html Build Output lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
        Manifest merger failed : Attribute application@dataExtractionRules value=(string resource) from AndroidManifest.xml

        ```

        To fix this error, add `tools:replace="android:dataExtractionRules"` in the `<application>` tag in the `AndroidManifest.xml` file.
      </Accordion>

      <Accordion title="Fix conflict with allowBackup=&#x22;false&#x22;">
        If you add `android:allowBackup="false"` in the `AndroidManifest.xml`, you might get the following error:

        ```html Build Output lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
        Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:32:9-36
            is also present at [:airbridge] AndroidManifest.xml:27:9-35 value=(true).
            Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:30:5-250:19 to override.
        ```

        To fix this error, add `tools:replace="android:allowBackup"` in the `<application>` tag in the `AndroidManifest.xml` file.
      </Accordion>

      <Accordion title="If compileSdkVersion is less than 31">
        Since the android:dataExtractionRules feature was added from API Level 31, you might get the following error if compileSdkVersion is less than 31:

        ```html Build Output lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
        AndroidManifest.xml: AAPT: error: attribute android:dataExtractionRules not found.
        ```

        To fix this error, add `tools:remove="android:dataExtractionRules"` in the `<application>` tag in the `AndroidManifest.xml` file.
      </Accordion>
    </AccordionGroup>
  </Accordion>

  <Accordion title="Resolve Airbridge SDK backup rules merge conflict issue">
    If you are experiencing build errors caused by overlapping of the Airbridge SDK backup rules and third-party SDK backup rules, please refer to the workaround below.

    e.g) If you have an Airbridge SDK backup rule and an Appsflyer SDK backup rule that overlap, you will see the build error below.

    ```html lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
    Attribute application@fullBackupContent value=(@xml/appsflyer_backup_rules) from [com.appsflyer:af-android-sdk:6.6.1] AndroidManifest.xml:14:18-73
    is also present at [io.airbridge:sdk-android:2.14.0] AndroidManifest.xml:27:18-78 value=(@xml/airbridge_auto_backup_rules).
    Suggestion: add 'tools:replace="android:fullBackupContent"' to <application> element at AndroidManifest.xml:7:5-13:19 to override.
    ```

    To resolve this issue, please set up as follows.

    <AccordionGroup>
      <Accordion title="backup_rules.xml setup">
        1. Create a `src/main/res/xml` folder.
        2. Within the created xml folder, create a file (e.g. `custom_backup_rules.xml`).
        3. Add the data backup rules defined in the Airbridge SDK as follows.

        ```xml lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
        <?xml version="1.0" encoding="utf-8"?>
        <full-backup-content>
            <!-- Airbridge Backup Rules -->
            <exclude domain="sharedpref" path="airbridge-internal" />
            <exclude domain="sharedpref" path="airbridge-install" />
            <exclude domain="sharedpref" path="airbridge-user-info" />
            <exclude domain="sharedpref" path="airbridge-user-alias" />
            <exclude domain="sharedpref" path="airbridge-user-attributes" />
            <exclude domain="sharedpref" path="airbridge-device-alias" />
            <exclude domain="database" path="airbridge.db" />

            <!-- Appsflyer Backup Rules -->
            <exclude domain="sharedpref" path="appsflyer-data"/>

            <!-- Your Custom Backup Rules -->
        </full-backup-content>
        ```
      </Accordion>

      <Accordion title="data_extraction_rules.xml setup">
        <Info>
          **Note**

          The data\_extraction\_rules.xml setting is required for Airbridge Android SDK v2.27.1 and above.
        </Info>

        1. Within the created xml folder, create a file (e.g. `custom_data_extraction_rules.xml`).
        2. Add the data backup rules defined in the Airbridge SDK as follows.

        ```xml lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
        <?xml version="1.0" encoding="utf-8"?>
        <data-extraction-rules>
            <cloud-backup>
                <!-- Airbridge Backup Rules -->
                <exclude domain="sharedpref" path="airbridge-internal" />
                <exclude domain="sharedpref" path="airbridge-install" />
                <exclude domain="sharedpref" path="airbridge-user-info" />
                <exclude domain="sharedpref" path="airbridge-user-alias" />
                <exclude domain="sharedpref" path="airbridge-user-attributes" />
                <exclude domain="sharedpref" path="airbridge-device-alias" />
                <exclude domain="database" path="airbridge.db" />

                <!-- Appsflyer Backup Rules -->
                <exclude domain="sharedpref" path="appsflyer-data"/>

                <!-- Your Custom Backup Rules -->
            </cloud-backup>
            <device-transfer>
                <!-- Airbridge Backup Rules -->
                <exclude domain="sharedpref" path="airbridge-internal" />
                <exclude domain="sharedpref" path="airbridge-install" />
                <exclude domain="sharedpref" path="airbridge-user-info" />
                <exclude domain="sharedpref" path="airbridge-user-alias" />
                <exclude domain="sharedpref" path="airbridge-user-attributes" />
                <exclude domain="sharedpref" path="airbridge-device-alias" />
                <exclude domain="database" path="airbridge.db" />

                <!-- Appsflyer Backup Rules -->
                <exclude domain="sharedpref" path="appsflyer-data"/>

                <!-- Your Custom Backup Rules -->
            </device-transfer>
        </data-extraction-rules>
        ```
      </Accordion>

      <Accordion title="AndroidManifest.xml setup">
        ###### Airbridge Android SDK v2.27.1 or above

        ```xml lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
        <manifest
            ...
            xmlns:tools="http://schemas.android.com/tools">

            <application
                ...
                android:allowBackup="true"
                android:fullBackupContent="@xml/custom_backup_rules"
                android:dataExtractionRules="@xml/custom_data_extraction_rules"
                tools:replace="android:fullBackupContent,android:dataExtractionRules">
        ```

        ###### Airbridge Android SDK version less than v2.27.1

        ```xml lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
        <manifest
            ...
            xmlns:tools="http://schemas.android.com/tools">

            <application
                ...
                android:allowBackup="true"
                android:fullBackupContent="@xml/custom_backup_rules"
                tools:replace="android:fullBackupContent">
        ```
      </Accordion>
    </AccordionGroup>
  </Accordion>

  <Accordion title="Double brace initialization issue">
    ```java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
    HashMap<String, Object> semanticAttributes = new HashMap();
    semanticAttributes.put("products", Arrays.asList(
            // double brace initialization issue
            new HashMap<String, Object>() {{
                put("name", "MacBook Pro");
                put("price", 1548200);
                put("position", 1);
                put("brandID", 23);
                put("brandName", "apple");
            }},
            new HashMap<String, Object>() {{
                put("name", "MacBook Air");
                put("price", 1500000);
                put("position", 2);
                put("brandID", 23);
                put("brandName", "apple");
            }}
        )
    );

    HashMap<String, Object> customAttributes = new HashMap();
    customAttributes.put("customKey", "customValue");

    Airbridge.trackEvent(
        "purchase",
        "action",
        "label",
        3048200,
        customAttributes,
        semanticAttributes
    );
    ```

    The Android SDK uses Google's GSON library and there is a [known issue regarding the double brace initialization](https://github.com/google/gson/issues/346).  The product data may be missing when using double brace initialization for creating the product items as shown in the above Java code. Therefore, it is recommended to create the product items (e.g., [Order Complete ](/en/developers/deprecated-android-sdk-v2#order-complete)event) manually.
  </Accordion>
</AccordionGroup>
