Facebook Audience Network

 
 
 

Getting Started

Facebook Audience Network allows you to monetize your Android apps with Facebook ads. This guide will walk you through all the steps to integrate the SDK.

Prerequisites

Ensure that you have Android Studio installed.

Getting Started Steps

Step 1: Creating a New Project

Step 2: Including the SDK

Step 1: Creating a New Project

You can skip this step if you already have a project you want to integrate Audience Network into.

Start Android Studio and select "Start a new Android Studio Project"



Name your project and specify your company's domain.
The Package name will be your identifier if you decide to upload your app to the Google Play store.



Set your minimum Android SDK version. Audience Network requires API 15 or higher, but for the sake of
these samples, we will use API 21.



Add an Empty Activity to your Project



Name your initial Activity and click Finish.

Step 2: Including the SDK

The Audience Network SDK is part of the Facebook SDK. Follow these steps to download and include it in your project:

Using Gradle



Add the following compile statement to your app-level build.gradle (not project!), to use the latest Audience Network SDK:

dependencies {
  ...
  compile 'com.facebook.android:audience-network-sdk:4.+'
}

If there are issues resolving the Audience Network SDK, make sure that you've synced your Gradle file and try restarting Android Studio.

Manual installation (Not Recommended)

If using Intellij IDEA or Eclipse, download and extract the Audience Network SDK for Android. Under the AudienceNetwork/bin folder, copy the AudienceNetwork.aar file and place it in the /libs folder in your project you might need to create the directory if it doesn't already exist. Then, add the following lines to your app's build.gradle:

repositories {
  flatDir {
    dirs 'libs'
  }
}

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

If using AudienceNetwork.jar for your project, under the AudienceNetwork/bin folder, rename the AudienceNetwork.aar to AudienceNetwork.zip, extract classes.jar file and rename it to AudienceNetwork.jar, place the AudienceNetwork.jar file in the /libs folder in your project you might need to create the directory if it doesn't already exist. Make sure your IDE's UI reflects this change. If you are using Intellij IDEA or Eclipse, right click on the libs/AudienceNetwork.jar file and choose 'Add as Library'.


Though not required, we recommend that you set up your project to work with Google Play Services as indicated here. This will enable the Audience Network SDK to fetch the Advertising ID more efficiently.

Next Steps