Search code examples
androidadmobchartboostinmobiadcolony

Interstitial AdMob mediation on Android


I'm implementing mediation of Interstitial Ads through AdMob on Android. I would like to integrate 4 additional ad networks:

InMobi, AdColony, Chartboost, and Applovin.

As far as I understood by reading the official documentation on each website, enabling interstitial ad mediation is as easy as:

  • Creating an account on each of the ad networks above
  • Integrating the SDK and the adapter for AdMob
  • Activating mediation for each of the networks above through the AdMob website
  • Initializing/configuring the SDKs before creating an AdRequest

Here's my code for the initialization of the SDKs:

                InMobiSdk.init(adContext, "xxxxxxxxxxxxx");
                InMobiSdk.setGender(InMobiSdk.Gender.MALE);
                InMobiSdk.setYearOfBirth(1993);

                AppLovinSdk.initializeSdk(adContext);

                AdColony.configure((Activity) adContext, "version:2.3.0,store:google", "xxxxxx", "xxxxxxxxxx");

                Chartboost.startWithAppId((Activity) adContext, "xxxxxxxxxx", "xxxxxxxxxxx");
                Chartboost.onCreate((Activity) adContext);

After doing that I create the AdRequest:

        mInterstitialAd = new InterstitialAd(adContext);
        mInterstitialAd.setAdUnitId("xxxxxxxxxxx");
        AdRequest adRequest = new AdRequest.Builder()
                .setGender(AdRequest.GENDER_MALE)
                .setBirthday(new GregorianCalendar(1993, 1, 1).getTime())
                .build();
        mInterstitialAd.loadAd(adRequest);

Unfortunately, I can't see any interstitial other than the ones provided by Google and I can't figure out what I'm doing wrong. I tried to find some information in the debug logs but I didn't find anything useful.

On the other hand, mediation with banner ads is working like a charm.

Is there any additional implementation step that I should do to get ad mediation work?


Solution

  • After a lot of investigation and digging, I figured it out.

    In order for the mediation to work, you need to create the appropriate proguard (obfuscation tool available by default in Android Studio) rules.

    This is needed in order to allow the AdMob SDK to find your adapter class (the obfuscation process renames all classes, except those for which there's a proguard rule) and instantiate it.

    Hope it will help other developers who have been struggling with this issue.