Google Mobile Ads Mediation Adapter v1.4.0

Millennial Media provides a Google Mobile Ads mediation adapter for developers using AdMob. For other mediation solutions please contact the mediator directly.

Please note that the adapter is only compatible with Millennial SDK version 6.3.0 and higher.

Click here to download the Google Mobile Ads mediation adapter.

Adapter Integration Guide

This integration guide assumes that you have already integrated the Google Mobile Ads SDK into your app project. You will need a placement ID and site ID from One by AOL (Nexage) and an ad unit ID from AdMob.

Note on Selectively Compiling Google Play Services

If you are selectively compiling Google Play Services APIs with your app, you MUST include the base component as the MM SDK is dependent on it. To include the base APIs, add the following to your application’s build.gradle:

com.google.android.gms:play-services-base:11.0.4

Again, this is only required if you are NOT including the entire Google Play Services API (i.e. com.google.android.gms:play-services).

1. Integrate the MillennialMedia library with your project.

Follow the instruction steps in our SDK integration guide. You may include location information, though this will be provided through the Google Ads connector and not directly through the Millennial SDK.

2. Add the mediation adapter to your project.

Add the Android Google Ads MM Adapter .aar file (above) into the libs directory in your project. To reference .aar files in your libs folder you must add the flatDir object to your project’s build.gradle file:

allprojects {
    repositories {
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

You can then reference the .aar in the application’s build.gradle file as shown below:

compile(name:'android-google-ad-mm-adapter-1.4.0-c41b7612', ext:'aar')

3. Add One by AOL (Nexage) as an ad source on AdMob

You should add One by AOL (Nexage) as a supported mediation ad source for each placement. AdMob will provide you with ad unit IDs for each banner or interstitial placement, which are now ready to request and display Millennial ads based on your mediation settings.

Please be sure to add both your site ID and placement ID to the mediation ad source configuration!

4. Initialize the MM SDK

MMSDK.initialize(Application application) should be explicitly called prior to any mediation to the MM SDK. This should be called within the onCreate method of your Application subclass. Calling this method anywhere else is not supported. The MMSDK.initialize(Activity activity) method introduced in SDK 6.0 has been deprecated and should no longer be used. Please see the sample app included in the SDK download for an example that includes error handling.

import com.millennialmedia.MMSDK;

MMSDK.initialize(this); // pass in a reference to your Application subclass instance

Note on using Google Ads without passing in an Activity

In the rare case that you are instantiating the Google Ads AdView or InterstitialAd class with a Context that is NOT an Activity, you must call the MMSDK.initialize method explicitly. In this instance, it is highly recommended that you extend the Application class and initialize the MM SDK during the onCreate phase of the Application. The MM SDK initialization code is shown here:

try {
   MMSDK.initialize(this); // pass in current Application instance
} catch (MMException e) {
   // handle initialization failure here
}

Again, this initialization is only required if you instantiate Google Ads with a Context that is NOT an Activity.

Supported Metadata

The Millennial SDK supports the following metadata that can be sent through the Google Ads connector:

  • Age
  • Gender
  • Keywords
  • Location
  • COPPA (i.e tagForChildDirectedTreatment)

See the AdMob documentation for more details.