Integrating the Android SDK

This guide describes how to integrate the DT Exchange SDK into your Android project, which uses Maven Central for dependency management.

Prerequisites

Android 4.4+ (API Level 19)

Step 1: Integrating the SDK in your App

You can integrate the DT Exchange SDK using either Maven Central dependencies or a manual download. Select one of the following options:

Configuring Maven Central

To add DT Maven repository and plugins to your Gradle build script:

  1. Add the following to your app product-level build.gradle inside the repositories section.

  2. At the root level build.gradle file, there are usually two repository sections - one for buildscript and one for allprojects. Add the entry in allprojects:

Groovy
allprojects {
  repositories {
    // add this
    mavenCentral()
  }
  // ...
}
  1. Add the following to the project app-level gradle file inside the dependencies section.

Manually Downloading the SDK

To download the DT Exchange Android SDK, click here:

↓ Android DTX SDK 8.4.3
  1. Copy the following files from the Fyber Marketplace SDK folder to your project libs folder.

    • For version 8.4.3:

      fyber-marketplace-8.4.3.aar

    • For version 8.1.0 and above (for Open Measurement support):

      omsdk-android-1.5.4-release.aar

  2. Add the following repositories and dependencies to the project build.gradle file:

Step 2: Integrating Google Play Services

DT recommends using Google Play Services to access your Google Advertising ID. This ID tracks your app's daily active users (DAU), and many ad campaigns require it. Without the ID, ad inventory is limited.

  1. In the app-level build.gradle file, add the following dependencies:

  1. For apps targeting API Level 31 (Android 12) or higher, declare the Google Play Services permission in the AndroidManifest.xml file. This step is required unless the app uses a recent Google Mobile Ads SDK version.

For further information about Google Advertising ID Restrictions, read the following:

Google Advertising ID Restrictions

chevron-rightPermission Required for Advertising IDhashtag

Google Advertising ID (GAID) is a unique string identifier that anonymously identifies a device for advertising purposes. Google Play Services provides this Advertising ID and enables users to opt out of personalized ads in apps or reset their identifier. When a user resets their identifier, it can connect to a previous identifier.

In 2021, Google announced a behavior change for apps targeting Android 13arrow-up-right (API Level 33) and higher, a AD_ID permission is required. For more information, see Advertising IDarrow-up-right.

To receive the Advertising ID, developers must add a new permission to the manifest file unless the app uses a recent version of the Google Mobile Ads SDK:

XML

Recent versions of the Google Mobile Ads SDK (play-services-ads v20.4.0 and higher, or play-services-ads-identifier v17.1.0 and higher) include this permission. If the app uses these SDKs, the AD_ID permission from the SDK's library manifest merges with your app's main manifest by default, making the Advertising ID available.

For more information about Google Play Services, see Set Up Google Play Servicesarrow-up-right.

Step 3: Adding Permissions - Android Manifest File

  1. Add the following mandatory permission to your AndroidManifest.xml file:

  1. To enhance targeting capabilities, add these permissions:

circle-info

The ACCESS_NETWORK_STATE permission differentiates WiFi from a cellular network.

Step 4: Initializing the SDK

SDK initialization is mandatory because the DT SDK relies on the Console configuration for functionality. Without it, the SDK won't operate, and no ads will display. DT recommends performing this step during the app's initialization. Follow these steps to initialize the SDK.

Google Play Families Ads API

To participate in the Google Play Families Ads program, run the following code to indicate if the user is a child:

circle-info

Call this API once per app session before initializing the SDK. If the app doesn't contain the API, the user is not considered a child user by default.

After configuring your AndroidManifest file and preparing to request ads, initialize InneractiveAdManager.initialize(context, <"appID">), and pass on your Activity or application context with the following code:

circle-info

Call InneractiveAdManager.destroy() when you no longer need the library to display more ads, as this release any resources used by the SDK.

circle-check

Locating the App ID

To locate the App ID on the DT Console:

  1. From the DT Consolearrow-up-right, go to Monetization→App Management. The Apps dashboard window appears.

  2. Navigate to the required app. The App ID appears below the app's name.

Initialization Callback

You can use the following initialization callback to InneractiveAdManager to monitor the SDK's initialization status:

Valid values:

  • SUCCESSFULLY: SDK initialized successfully.

  • FAILED_NO_KITS_DETECTED: Only the core DT Exchange library detected. Check dependencies and add the video-kit and mraid-kit.

  • FAILED: SDK failed to communicate with servers. Retry initialization.

  • INVALID_APP_ID: Incorrect app ID. Verify configuration or contact support.

circle-exclamation

Passing a User ID to the SDK

To set a User ID for the SDK session, run the following code:

circle-check

The basic Android SDK integration is complete. You can now integrate other ad types as required. For more information, see Android Ad Formats.

circle-exclamation

User consent mechanisms comply with various data protection laws. The following regulations mandate that users' data be handled with explicit consent:

GDPR

The General Data Protection Regulation of the European Union (GDPRarrow-up-right) requires you to implement a user consent mechanism. A user is within the GDPR scope for your app when one or all of the following apply:

  • The user is currently located in the EU.

  • The user has registered with the app as an EU resident.

  • The app is specifically targeted to EU users.

To comply with EU regulations and ensure seamless ad monetization, DT recommends consulting a legal advisor to determine the best approach for your business and using a Consent Management Platform (CMP).

If you haven’t updated to SDK 8.3.0 or later, you need to manually configure consent values with your CMP. The SDK automatically retrieves these values from 8.3.0 and later, eliminating the need for manual setup. For a complete list of CMPs, see the Interactive Advertising Bureau - CMP Listarrow-up-right.

To incorporate GDPR consent values manually, set the setGdprConsent API in Boolean format, for example:

Valid values:

  • True: The user grants consent.

  • False: The user does not grant consent.

circle-exclamation

To set the GDPR consent string, use the following API:

To clear the consent flag and consent data, use the following API:

If you don't obtain the user's consent before sending the SDK, only contextual ads appear.

CCPA

The California Consumer Privacy Act of 2018 (CCPAarrow-up-right) protects the personal information of California residents and applies to all companies operating in California. If a California resident uses a mobile app developer's app, CCPA applies to the developer and every company that processes the personal information of the app's users.

For more information on CCPA and DT's practices, see US Privacy Compliance and IAB CCPA Compliance Frameworkarrow-up-right.

CCPA API

To set the CCPA consent string, use the following API:

DT supports the following values for the US Privacy String:

  • 1---: CCPA does not apply, for example, the user is not a California resident.

  • 1YNN: User does NOT opt out, ad experience continues.

  • 1YYN: User opts out of targeted advertising.

For more information, see IAB US Privacy Stringarrow-up-right.

To clear the privacy setting flag and opt-out data, use the following API:

LGPD

The Brazilian General Data Protection Law, the Lei Geral de Proteção de Dados Pessoais (LGPDarrow-up-right), mandates processing personal data for legitimate, specific, explicit, and communicated purposes.

To set the LGPD consent values, use the following API:

Valid values:

  • IALGPDConsentTypeGiven: True.

  • IALGPDConsentTypeDenied: False.

If the consent value is not set, the default is False.

COPPA

The Children's Online Privacy Protection Act of 1998 (COPPAarrow-up-right) is a federal law that imposes specific requirements on websites and online service operators to protect the privacy of children under 13.

COPPA API for Flagging Specific Users

Android SDK 8.2.3 and later supports the COPPA API, which allows publishers to flag specific end users as children as required under COPPA.

circle-exclamation

To confirm that the target audience of the application applies to COPPA, use the following API:

circle-info

It is the publisher’s responsibility to decide whether to use the COPPA API or to treat all users as children. If you want flag all users as children, see COPPA.

Step 6: Configure Parameters

To add gender and age parameters, use the following API:

Step 7: app-ads.txt

The app-ads.txt standard helps prevent the unauthorized selling of in-app inventory and app domain spoofing.

For more information about how to list your Developer Website URL in the Google Play Store, see Adding a Developer Website.

Step 8: (Optional ) Using the DT Exchange SDK in Secure Only Mode

The InneractiveAdManager API enables you to control how the SDK should perform any network connections.

By invoking this setter with a value of true, all outgoing network connections from the DT Exchange SDK will use SSL/HTTPS. The default behavior is not to use secure connections.

circle-exclamation
circle-info

The Android application-level secure API (network-security-config cleartextTrafficPermitted) takes precedence over this value. If you set cleartextTrafficPermitted to false and invoke the useSecureConnections setter with a value of false, the SDK behaves as if you requested secure connections only.

Last updated