Enable AdMob Mediation on Android

AdMob Android adapter 6.10.3.0 is compatible with Vungle Android SDK 6.10.3 and has been tested for compatibility with Google Android SDK 20.4.0. Documentation for integrating AdMob Mediation with Vungle SDK resides on AdMob's Guide section, Integrating Vungle with Mediation, so use this guide as a supplement for the information about new features that are yet to be covered by the official documentation.

Download AdMob Android Adapter v6.10.3.0 and include Vungle Android SDK 6.10.3. You can add them to your project manually or do Gradle integration through Bintray.

implementation 'com.vungle:publisher-sdk-android:6.10.3'

The instructions for Android Studio integration and manual integration can be found on AdMob's integration guide, Step 3: Import the Vungle SDK and Adapter, at https://developers.google.com/admob/android/mediation/vungle#step_3_import_the_vungle_sdk_and_adapter.

COPPA

Starting with Vungle SDK v6.10.3, Vungle provides an optional method for you to indicate to the Vungle SDK at the device level whether the user within the given mobile app is under or over the age of 13. The Vungle SDK COPPA configuration respects AdMob's "tag for child-directed treatment."

To implement COPPA:

  1. Refer to our COPPA Implementation details.
  2. To beta-test the COPPA API, please contact Vungle Support at tech-support@vungle.com.

CCPA

As of July 1, 2020, California Consumer Privacy Act (CCPA) will be enforced and publishers must update to Android SDK 6.7.0 and AdMob adapter 6.7.0.0 to comply with CCPA.

To pass CCPA values, you must call the Vungle SDK API directly. This  is the only feature that should be accessed directly through Vungle SDK API. Other optional features such as Android ID and memory settings should use VungleNetworkSettings.

Use Vungle.updateCCPAStatus to set the user’s consent status to specify that the user has opted out by passing Vungle.CCPAStatus.OPTED_OUT. And use Vungle.getCCPAStatus to get the current CCPA status for the particular user.

CCPA API
updateCCPAStatus getCCPAStatus
public static void updateCCPAStatus(@NonNull final Vungle.CCPAStatus status)
Sample Code
// To set the user's CCPA status to opted out:
Vungle.updateCCPAStatus(Vungle.CCPAStatus.OPTED_OUT);
// To find out what the user's current consent status is:
Vungle.CCPAStatus currentCCPAStatus = Vungle.getCCPAStatus();

Banner Ad

Starting with v6.5.1, Vungle SDK supports AdMob’s banner adsTo display a banner ad in the application, create an MREC or banner placement on Vungle dashboard and configure this to a banner ad unit on AdMob dashboard. Please note that MREC (300dp x 250dp) must have a separate placement reference ID configured as MREC from Vungle dashboard, compared to other banner sizes that is configured as banner.

Supported banner sizes:

Size in dp (WxH) Description AdSize constant
320x50 Banner BANNER
728x90 IAB Leaderboard LEADERBOARD
300x250 IAB Medium Rectangle MEDIUM_RECTANGLE
Provided width x Adaptive height Adaptive banner N/A
Screen width x 32|50|90 Smart banner SMART_BANNER

Sample code:

AdView adView = new AdView(this);
adViews.add(adView);
adView.setAdSize(AdSize.MEDIUM_RECTANGLE);
adView.setAdUnitId(<AdUnit>);

 

Multiple Banner Load

Vungle Android SDK 6.5.x supports one banner ad to be loaded for a placement ID at any given time and one placement ID is mapped to one AdMob ad unit ID. This limits the ability to successfully load subsequent loadAd requests when a banner ad is already loaded by Vungle SDK. To overcome this limitation, you must pass a unique identifier (which can be a random number generated or simple incremental number) for each banner loadAd so the request can fall back to next ad network in the waterfall when Vungle SDK already has a banner ad loaded.

Sample code:

Bundle extras = new VungleExtrasBuilder(null).setBannerUniqueRequestID("12345").build();
AdRequest adRequest = new AdRequest.Builder().addNetworkExtrasBundle(VungleInterstitialAdapter.class, extras).build();
adViewBanner.loadAd(adRequest);

Network-Specific Parameters

The Vungle AdMob adapter continues to support network specific parameters as shown on AdMob's guide. Starting with v6.5.1, audio setting for video play has been replaced by setStartMuted that takes a boolean and setSoundEnabled has been deprecated. The adapter also supports an additional parameter setAdOrientation to play the ad as per device orientation that takes an AdConfig object with LANDSCAPE, PORTRAIT, AUTO_ROTATE and MATCH_VIDEO configurability. (setAutoRotate has been deprecated)

Sample code:

Bundle localExtras = new VungleExtrasBuilder(null)
        .setAdOrientation(AdConfig.LANDSCAPE)
        .setStartMuted(true)
        .setUserId("vungle-test-user")
        .build();

For rewarded ads, you will pass VungleAdapter.class on addNetworkExtrasBundle while you will pass VungleInterstitial.class for interstitial ads.

Sample code for loading rewarded ads:

AdRequest adRequest = new AdRequest.Builder()
        .addNetworkExtrasBundle(VungleAdapter.class, localExtras)
        .build();

RewardedAd.load(this, "AD_UNIT_ID", adRequest, new RewardedAdLoadCallback(){
    @Override
    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) { }

    @Override
    public void onAdLoaded(@NonNull RewardedAd rewardedAd) { }
});

Sample code for loading interstitial ads:

AdRequest adRequest = new AdRequest.Builder()
        .addNetworkExtrasBundle(VungleInterstitialAdapter.class, localExtras)
        .build();
 
InterstitialAd.load(this, "AD_UNIT_ID", adRequest, new InterstitialAdLoadCallback() {
    @Override
    public void onAdLoaded(@NonNull InterstitialAd interstitialAd) { }
 
    @Override
    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) { }
});

Memory Settings

Starting with v6.4.11, you can prevent the SDK from requesting ads or even initializing if the storage of your Android phone falls below a predefined threshold. If this happens, you will get an error similar to the following:

There is not enough file system size on the device. 

Sample code:

import com.vungle.mediation.VungleNetworkSettings;

//Integer value sets the required minimum available free storage space to be able to initialize the SDK
VungleNetworkSettings.setMinSpaceForInit(<INTEGER_VALUE>);

//Integer value sets the required minimum available free storage space to be able to request an ad
VungleNetworkSettings.setMinSpaceForAdLoad(<INTEGER_VALUE>);

Android ID

Starting with v6.4.11, publishers can now restrict from passing Android ID from the device to the SDK.

Sample code:

VungleNetworkSettings.setAndroidIdOptOut(true);

 

Powered by Creativity Driven by Performance Sign Up Here

Questions?

Need further assistance, feel free to reach out to us, we’re here to help!

Was this article helpful?