Get Started with Android

Audience Network is bidding only

Audience Network exclusively uses bidding to serve ads in iOS and Android apps.

Meta Audience Network enables you to monetize your Android apps using Facebook ads. This guide walks you through every step required to integrate the SDK.

Prerequisites

Make sure you have Android Studio installed.

Please see the FAQ for minimum OS version supported by Audience Network SDK.

Step 1: Creating a New Project

Step 2: Including the SDK

Step 3: Integration Error Mode (optional)

Code Sample

Java and Kotlin code samples are available in our GitHub repository.

Step 1: Creating a New Project

If you already have an existing project where you want to integrate Audience Network, you can skip this step.

Open Android Studio and select New Project.

Select a Empty Activity to add it to your project and then click Next.

Give your project a name and provide your company's domain. The Package name serves as your app's unique identifier if you choose to publish it on the Google Play Store.

Configure the minimum Android SDK version. Audience Network requires API 24 or higher.

Step 2: Including the SDK

The Audience Network SDK is bundled as part of the Facebook SDK. Complete the following steps to download and add it to your project:

Using Gradle

Add the following implementation statement to your app-level build.gradle file (not the project-level one) to pull in the latest Audience Network SDK:

dependencies {
implementation 'com.facebook.android:audience-network-sdk:6.+'
}

If you encounter issues resolving the Audience Network SDK, verify that your Gradle file is synced and try restarting Android Studio.

Manual installation (Not Recommended)

Download and extract the Audience Network SDK for Android. Navigate to the AudienceNetwork/bin folder, copy the AudienceNetwork.aar file, and place it in the /libs folder within your project. You may need to create this directory if it does not already exist. Then, add the following lines to your app's build.gradle:

repositories {
flatDir {
dirs 'libs'
}
}

dependencies {
...
implementation(name: 'AudienceNetwork', ext: 'aar')
}

The Audience Network SDK depends on Google Play Services (play-services-ads-identifier and play-services-basement) to retrieve the Advertising ID. Make sure your project is configured to use Google Play Services as described here.

Step 3: Integration Error Mode (optional)

During Audience Network SDK integration, the integration error mode setting helps you verify that your implementation is working correctly. This method gives you control over how the SDK behaves when it detects incorrect usage.

  • INTEGRATION_ERROR_CRASH_DEBUG_MODE: The app crashes if your build has the Android FLAG_DEBUGGABLE flag set. Otherwise, INTEGRATION_ERROR_CALLBACK_MODE is used instead (recommended during testing).
  • INTEGRATION_ERROR_CALLBACK_MODE: The app invokes the AdListener.onError(Ad, AdError) callback whenever an integration error is detected.
// Example for setting the SDK to crash when in debug mode
AdSettings.setIntegrationErrorMode(INTEGRATION_ERROR_CRASH_DEBUG_MODE);

Next Steps