Mopub network mediation

If you already have the Mopub SDK integrated in your application code and you don't want to add more boilerplate code for ads the mediation publisher sdk allows you to integrate instal ads and networks into mopub without changing a single line of code.



In order to use the mopub's network mediation with instal you have to add the instal mediations sdk dependency to your project, and provide the mopub sdk and the instal publisher sdk dependencies in the file.

The publisher sdk and the publisher-mediation sdk are hosted on bitbucket, so you'll need to add the repository to your repositories as follows

repositories {
    // Other repositories
    maven { url '' }

And then add the dependencies

    compile('com.mopub:mopub-sdk:4.9.0@aar') {
        transitive = true

    compile 'com.instal:instal-publisher-sdk:1.0.24'

    compile 'com.instal:instal-publisher-sdk-mediations:0.0.1'


So you have to configure your mopub adunits to support instal custom classes, using the networks panel edit or create an adunit (Banner, Intertitial or native), then provide the custom configuration as follows:

Ad Type Custom Event Method Custom Event Class Custom event class data
Banner empty com.mopub.nativeads.MopubInstalBanner {"ad_unit": "Your instal ad unit"}
Interstitial empty com.mopub.nativeads.MopubInstalInterstitial {"ad_unit": "Your instal ad unit"}
Native empty com.mopub.nativeads.MopubInstalNative {"ad_unit": "Your instal ad unit"}

Mopub configuration example:

Mopub adunit configuration

Requesting ads

We're done, when you execute an ad request trough mopub using the previously configured ad unit the mopub sdk will automatically instantiate and invoke the instal mediator sdk classes using the provided ad unit, mopub will also provide fallback ads if the third part network fails to load.

All following examples are provided by the mopub docs

Request Interstitial

        MoPubInterstitial mInterstitial = new MoPubInterstitial(this, MOPUB_INTERSTITIAL_ADUNIT);

Request Banner

Instal banner view will be automatically inserted into the MoPubAdView contained in your layout

        MoPubView moPubView = (MoPubView) findViewById(;

Native ads

Mopub sdk will automatically fill the native ads fields (such as title,text,icon...) using your instal ad unit

Check mopub documentation for further details

Native ads in listview example:

  String[] testArray = {"1", "2", "3", "4"}; // Actual list view items

        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.base_row,, testArray); // List view adapter

        ViewBinder viewBinder = new ViewBinder // Mopub ad view binder

        // Render and positioning rules
        MoPubNativeAdPositioning.MoPubServerPositioning adPositioning = MoPubNativeAdPositioning.serverPositioning();
        MoPubStaticNativeAdRenderer adRenderer = new MoPubStaticNativeAdRenderer(viewBinder);

        // Mopub list adapter wrapper
        MoPubAdAdapter mAdAdapter = new MoPubAdAdapter(this, adapter, adPositioning);


        // Native ad request
        RequestParameters.Builder myRequestParameters = new RequestParameters.Builder();




The following step is only necessary if you are using Proguard to obfuscate your code

-keep class com.mopub.nativeads.** { *; }
-dontwarn com.mopub.nativeads.**
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);

-keep class com.instal.** { *; }
-dontwarn com.instal.**
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);


If everything has been configured correctly as ads are loaded you should see the following message in your android logcat :

instal.mediationapp I/InstalAd: Fetching ad for task #0
instal.mediationapp D/InstalAd: Loading custom event adapter.
instal.mediationapp D/InstalAd: adLoaded