Integrating Third Party Ad Networks

The MoPub SDK can mediate most ad networks through our pre-built adapters, server-to-server integrations, and custom events. To see the latest list of supported ad networks, and to get the latest certified versions of mediation adapters, visit the MoPub Mediation Integration Tool. The tool also provides a convenient integration approach, discussed below.

This guide walks you through the mediation setup process, specifically where to download adapters and how to integrate them into your app project.

Integrate adapters from Bintray/JCenter

The MoPub Mediation Integration Tool provides a new and convenient integration approach. Simply select the ad networks you would like to mediate, and the page will output the Gradle configuration information to include in your app. If you are getting started with mediation and do not need to tweak anything, this approach will be the most beneficial.

Integrate adapters via source code (GitHub)

If you prefer to manually integrate adapters using the existing process, you can continue to do so. Our mediation adapters have been migrated to a new GitHub repository.

1. Download the mediation adapters

Within the repository, you can find .java adapter files grouped by ad networks. Simply clone the entire repository or manually download the adapter files that you would like to use.

2. Add the adapter files to your app project

In your app project, make sure the following directory paths exist (if you are a new publisher, you might not have them). You will need to place the adapter files into the respective directory depending on the ad format(s) you would like to mediate.

  • [app's src]/.../com/mopub/mobileads (for banner, interstitial, and rewarded video)
  • [app's src]/.../com/mopub/nativeads (for native ad - be sure to register your ad renderers, shown below)

3. Import third-party SDKs

Incorporate the third party SDKs into your project. This typically involves adding that network’s SDK .jar file to a libs directory, or adding its Gradle dependency (if available). This information can usually be found on the ad network’s support page.

4. You are all set!

That’s it! Be sure to visit the MoPub dashboard to set up the corresponding network campaigns and target the proper ad units. For additional network tips, take a look at our Frequently Asked Questions.

(Native Ad) Set up your ad renderers

If native ad is among the formats you are mediating, to ensure your native ad views are laid out as intended, create and register the appropriate renderer for each ad network. Don’t forget the default MoPubStaticNativeAdRenderer, shown below.

// Some third party SDKs rely on the MoPub renderer as a default renderer.
MoPubStaticNativeAdRenderer moPubStaticNativeAdRenderer = new MoPubStaticNativeAdRenderer(
    new ViewBinder.Builder(R.layout.native_ad_list_item)

Similarly, create ad renderers for third-party ad networks. As of the release of the AdMob native ad adapters, the GooglePlayServicesAdRenderer instance now requires a MoPub MediaViewBinder for compatibility with AdMob’s MediaView:

// AdMob
final GooglePlayServicesAdRenderer googlePlayServicesAdRenderer = new GooglePlayServicesAdRenderer(
    new MediaViewBinder.Builder(R.layout.native_video_layout)
        .mediaLayoutId( // bind to your `com.mopub.nativeads.MediaLayout` element

Flurry uses its own FlurryViewBinder that wraps the regular ViewBinder created above. You may register the Flurry renderer like so:

FlurryViewBinder flurryViewBinder = new FlurryViewBinder(new FlurryViewBinder.Builder(viewBinder));
FlurryNativeAdRenderer flurryNativeAdRenderer = new FlurryNativeAdRenderer(flurryViewBinder);

Starting with the 4.99.0 release of the Facebook Audience Network SDK, you will be using a dedicated ViewBinder for Facebook (FacebookViewBinder), like so:

FacebookAdRenderer facebookAdRenderer = new FacebookAdRenderer(
    new FacebookAdRenderer.FacebookViewBinder.Builder(R.layout.native_ad_list_item)
        // Binding to new layouts from Facebook 4.99.0+
        .advertiserNameId( // Bind either the titleId or advertiserNameId depending on the FB SDK version
        // End of binding to new layouts

To know which specific layout elements to use in your XML for the MediaView, AdIconView, and AdChoices RelativeLayout in the FacebookViewBinder, please reference this sample XML layout. Additionally, depending on the Facebook SDK version you are integrating, you will need to show only either the ad title or the advertiser name. For more information about Facebook’s implementation requriements, check out this article.

Then, register your ad renderers, like below. Your classThatRegistersAdRenderers varies depending on which native ad integration you are using. Remember to register your MoPubStaticNativeAdRenderer instance last.

// MoPubRecyclerAdapter
MoPubRecyclerAdapter classThatRegistersAdRenderers = new MoPubRecyclerAdapter(...);

// MoPubStreamAdPlacer
MoPubStreamAdPlacer classThatRegistersAdRenderers = new MoPubStreamAdPlacer(...);

// MoPubAdAdapter
MoPubAdAdapter classThatRegistersAdRenderers = new MoPubAdAdapter(...);

// MoPubNative
MoPubNative classThatRegistersAdRenderers = new MoPubNative(...);


Last updated December 13, 2018

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2018 MoPub Inc.