Use this guide to add Vungle Android SDK into your app, using MoPub as your main advertising mediation layer. MoPub Android adapter 6.10.2.0 is compatible with Vungle Android SDK 6.10.2.
- Vungle Android SDK 6.10.2
- Integrate MoPub Android Adapter 6.10.2.0
- Vungle Android SDK integration documentation for the SDK specific requirements and information
Before You Begin
- The Vungle Android SDK 6.10.2 has been tested with MoPub Android SDK 5.18.0 and is not compatible with 5.12.0 and lower.
- Please follow Integrate the MoPub SDK for Android guide to integrate with MoPub mediation and Vungle supports following ad formats.
- Please follow MoPub's guide to set up Vungle as a mediation network: https://developers.mopub.com/publishers/mediation/networks/vungle/.
- You will need the Vungle’s App ID and all the placement reference IDs you want to use in your app. You can find these credentials from the Vungle Dashboard (refer to Setting Up and Reporting on Placements).
CCPA
As of July 1, 2020, the California Consumer Privacy Act (CCPA) is enforced and publishers must update to Vungle Android SDK v6.7.0 and MoPub adapter v6.7.0.0 to comply with CCPA.
To pass CCPA values, 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 VungleAdapterConfiguration
class provided in the adapter.
Use Vungle.updateCCPAStatus
to set the user’s consent status; specify that the user has opted out by passing Vungle.Consent.OPTED_OUT
. Use Vungle.getCCPAStatus
to get the current CCPA status for a particular user.
In accordance with CCPA, the consent status is opted in by default unless Vungle.updateCCPAStatus
has been explicitly called to set it as opted out. Vungle.getCCPAStatus
may return null if not set but will be treated as opted-in.
CCPA API
public static void updateCCPAStatus(@NonNull final Vungle.Consent status)
public static Vungle.Consent getCCPAStatus()
Sample Code
// To set the user's CCPA status to opted out:
Vungle.updateCCPAStatus(Vungle.Consent.OPTED_OUT);
// To find out what the user's current consent status is:
Vungle.Consent currentCCPAStatus = Vungle.getCCPAStatus();
Banner Ad
Vungle supports following banner ad sizes: Banner, MREC, Leaderboard. Use an ad container that is no smaller than the specified size, and use the corresponding MoPubView.MoPubAdSize
height value when loading banner ads. Note that the MREC (300dp x 250dp) format must have its own, separate placement reference ID. An MREC format must be configured as 'MREC' in the Vungle dashboard, as opposed to the way that multiple banner sizes can all be configured under the same placement ID as 'banner'.
MoPubAdSize | Size |
HEIGHT_50 | 320dp x 50dp |
HEIGHT_90 | 728dp x 90dp |
HEIGHT_250 | 300dp x 250dp |
HEIGHT_280 | 300dp x 250dp |
MATCH_VIEW | Closest size that will fit in the view container |
Sample Code
@Override
public MoPubView.MoPubAdSize getAdSize() {
return MoPubView.MoPubAdSize.HEIGHT_250;
}
Optional Advanced Settings
Early SDK Initialization (Recommended)
MoPub Android SDK v5.5.0 and higher allows you to early initialize ad network SDK when the MoPub SDK completes initialization. We strongly recommend you to use this feature because it will allow additional time for the Vungle SDK to pre-cache an ad and have it ready to play at the next display opportunity.
Sample Code
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
Map<String, String> vungleSettings = new HashMap<>();
vungleSettings.put("appId", "YOUR_VUNGLE_APP_ID");
SdkConfiguration configBuilder = new SdkConfiguration.Builder("MOPUB_AD_UNIT_WITH_VUNGLE_PLACEMENT")
.withMediatedNetworkConfiguration(VungleAdapterConfiguration.class.getName(), vungleSettings)
.build();
MoPub.initializeSdk(this, configBuilder, initSdkListener());
Memory Settings
Starting with Vungle SDK v6.4.0, you can prevent the SDK from downloading, requesting ads, or even initializing if the storage of your Android device falls below a predefined threshold.
These are the option keys available:
Keys |
Type/Value |
Description |
pre_key_min_space_for_init |
String, value in bytes (default 51 MB) |
Sets the required minimum available free storage space to be able to initialize the SDK |
pre_key_min_space_for_ad |
String, value in bytes (default 50 MB) |
Sets the required minimum available free storage space to be able to request an ad |
Sample Code
Map<String, String> vungleSettings = new HashMap<>();
vungleSettings.put("appId", "YOUR_VUNGLE_APP_ID");
vungleSettings.put("VNG_MIN_SPACE_INIT",
mPreferences.getString("pref_key_min_space_for_init", String.valueOf(20 * 1024 * 1024)));
vungleSettings.put("VNG_MIN_SPACE_LOAD_AD",
mPreferences.getString("pref_key_min_space_for_ad", String.valueOf(20 * 1024 * 1024)));
Restrict Use of Device ID
Starting with Vungle SDK v6.4.10 and onward, you can now restrict the SDK from passing the Android ID from the device to the SDK.
Map<String, String> vungleSettings = new HashMap<>();
vungleSettings.put("appId", "YOUR_VUNGLE_APP_ID");
vungleSettings.put("VNG_DEVICE_ID_OPT_OUT",
String.valueOf(mPreferences.getBoolean("pref_key_key_android_id_opted_out", true)));
Interstitial Ads
You can pass custom ad configuration settings to customize your ad experience when load
is issued for MoPubInterstitial
. Note that VungleMediationSettings
has been deprecated as of Vungle SDK v6.5.1.0 and replaced with VungleMediationConfiguration
.
Attribute |
Default Value |
Description |
withStartMuted |
true |
Play ad with sound muted or unmuted. Set to 'true' to play muted. Set to 'false' to play with sound. |
withAutoRotate |
AdConfig.AUTO_ROTATE |
Available Orientation:
|
Sample Code
VungleMediationConfiguration vungleMediationConfiguration = new VungleMediationConfiguration.Builder()
.withAutoRotate(AdConfig.LANDSCAPE)
.withStartMuted(true)
.build();
mMoPubInterstitial.setLocalExtras(vungleMediationConfiguration.getExtrasMap());
mMoPubInterstitial.load();
Rewarded Ads
You can pass custom ad configuration to customize your ad experience when load
is issued for MoPubRewardedVideos
. Note that VungleMediationSettings
has been deprecated as of Vungle SDK v6.5.1.0 and replaced with VungleMediationConfiguration
.
Attribute |
Default Value |
Description |
|
null |
Sets the unique user ID to pass to your application to verify that this user should be rewarded for watching an incentivized ad. |
|
false |
Sets the starting sound state for the ad. If 'false', the audio respects device volume and sound settings. If 'true', video begins muted but user may modify. |
|
|
Available Orientation:
|
Sample Code
VungleMediationConfiguration vungleMediationConfiguration = new VungleMediationConfiguration.Builder()
.withUserId("VUNGLE_USER_ID")
.withStartMuted(true)
.withAutoRotate(AdConfig.LANDSCAPE)
.build();
MoPubRewardedVideos.loadRewardedVideo(mAdUnitId, vungleMediationConfiguration);