Integration Guide

The Millennial Media Android Ad SDK provides functionality for monetizing your Android applications. With the SDK, you can easily integrate inline, interstitial, and native ads into your application.


  • Android version 4.1 and up (API level 16+)
  • Google play services
  • Android Support Library v4 25.0.0+
  • Gradle based build system
  • Build environment with Java 7

Adding the SDK to your project

1. Add the following permissions and provider within the AndroidManifest.xml for the application

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission-sdk-23 android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22"/>
<uses-permission android:name="android.permission.NFC"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

NOTE: Information about how location works with SDK 6, is available here

	android:exported="false" />

NOTE: Publishers using Unity should replace ${applicationId} with their application’s package due to an issue in the Unity Manifest Merger regarding the ‘$’ character. For example, if your application package is then the authorities attribute value should be

2. Update the application element within the AndroidManifest.xml to enable usesCleartextTraffic


NOTE: Beginning in Android API 28, clear text network traffic is disabled by default. Failing to allow clear text traffic may result in ads displaying incorrectly.

3. Initialize the MM SDK

MMSDK.initialize(Application application) must be called prior to any API calls into 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

4. Set the AppInfo to be passed along on ad requests

This is needed to set the site ID and can optionally be used to inform buyers that the user is subject to Children’s Online Privacy Protection Act (COPPA) restrictions. You can also optionally set whether to share the user’s advertising ID and/or the application package ID with ads to enable a more personalized ad experience.

import com.millennialmedia.AppInfo;

AppInfo appInfo = new AppInfo();

appInfo.setSiteId(<YOUR SITE ID>);




5. Set General Data Protection Regulation (GDPR) properties

In order to use the MM SDK to serve personalized advertising (based on information such as device advertising identifiers, location, and other personal data) to EU users, you need consent for the use of Oath ad products. Use setConsentRequired() to indicate if the user falls under GDPR jurisdiction. Use setConsentData() to set a consent string for the user. These values should be set after initialization and before requesting an ad. Consent information may be updated at anytime during the app’s execution should the user’s consent data or status change. Additional information can be found in the General Data Protection Regulation section.

// Set to true if the user falls under GDPR jurisdiction.

// Sets the IAB Consent String

6. Set the UserData to be passed along with all ad requests (Optional)

User data can be updated at any time but generally if the user data does not change it is best set after MMSDK.initialize.

Please note that the information set in this object will not be sent on ad requests for users under the jurisdiction of GDPR or similar future privacy regulations that have not consented to the use of their personal data for advertising purposes.

import com.millennialmedia.UserData;

UserData userData = new UserData().
	setPostalCode(<POSTAL CODE>).

Additional Topics