Use this guide to add Vungle Android SDK into your app, using MoPub as your main advertising mediation layer. MoPub Android adapter 6.3.24 is compatible with Vungle Android SDK 6.3.24.
Contents
- Before You Begin
- Step 1. Set Up Vungle as a Network
- Step 2. Add Vungle as a Third-Party Ad Network
- Configuration Options
- Additional Note
Before You Begin
- The Vungle Android SDK 6.3.24 has been tested with MoPub Android SDK 5.4.0.
- The MoPub Dashboard does not yet include Vungle placements. You can check placement level performance using our Reporting API for Publishers.
- MoPub must be set up in your app before starting this tutorial. For a step-by-step guide, refer to MoPub’s Getting Started Guide for Android.
- 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 IDs in the Vungle Dashboard (refer to Setting Up and Reporting on Placements).
- Vungle SDK requires Android OS 4.0 (Ice Cream Sandwich - API version 14) and up
Step 1. Set Up Vungle as an SDK Network or as a Custom Native Network
Set Up Vungle as an SDK Network
- Log in to the MoPub dashboard and select Networks from the main navigation panel.
- Click New Network.
and select Vungle. - In the Network Settings section, if you Enable reporting access, enter your Reporting API Key from the Vungle Dashboard.
- In App & Ad Unit Setup, enter the Vungle Application ID and Placement Reference IDs.
Set Up Vungle as a Custom Native Network
To ensure that the MoPub servers recognize the integrated Vungle Adapters, set up Vungle as a Custom Native Network in the MoPub dashboard.
- Log into the MoPub dashboard, and select Networks from the main navigation bar.
- Click New network button on the top right.
and select Vungle from the list.
- After creating Vungle as a Network, click on the name from the list of Networks. In the Set Up Your Inventory section, for each ad unit that will use the Vungle SDK to present video ads, ensure that the MoPub SDK can find the network adapter used to interact with the Vungle SDK:
- If you are using MoPub Rewarded Video for an Ad Unit, add
com.mopub.mobileads.VungleRewardedVideo
under the Custom Event Class section. - If you are using Interstitial for an Ad Unit, add
com.mopub.mobileads.VungleInterstitial
under the Custom Event Class section. - Add your Vungle App ID, placement reference ID of the placement to be called from the ad unit, and all placement reference IDs that will be used in the app in JSON format under the Custom Event Class Data.
- Set the placement Reference ID you want to link to the MoPub Ad Unit for pid.
Note: A default placement is created for each app automatically. You must provide its placement reference ID in this initialization step whether or not you plan to take advantage of the placements functionality. If you create multiple placements, provide all the reference IDs. - Make sure to link a placement that is set to rewarded type at Vungle dashboard to the MoPub Ad Unit that is set to Rewarded Video; and link a placement that is set to interstitial type at Vungle dashboard to the MoPub Ad Unit that is set to Fullscreen (320 x 480).
{ "appId":"5935efecc802d63d5100000f", "pid":"DEFAULT05223", "pids":"DEFAULT05223, PADUNIT49379, PADUNIT68848, PADUNIT04241, PADUNIT53279, PADUNIT08448" }
- If you are using MoPub Rewarded Video for an Ad Unit, add
Note: The Vungle SDK will cache an ad automatically for the placement you selected to be Auto Cached in the Vungle Dashboard. We highly recommend selecting the MoPub Ad Unit shown first or the Ad Unit shown most frequently as the Auto Cached placement.
Step 2. Add Vungle as a Third-Party Ad Network
To add the Vungle Android SDK into your app using MoPub mediation:
- Add all the Vungle-related adapter files (under
/Vungle/com/mopub/mobileads/
in the MoPub Adapter Repository) to the/src/main/java/com/mopub/mobileads/
directory in your app’s project. This step is necessary because the MoPub SDK references these files as “Custom Event Class properties” in the directory.
VungleInterstitial.java
VungleRewardedVideo.java
VungleRouter.java
VungleRouterListener.java
- Follow the instructions in the “Step 1. Include the Vungle SDK in Your Project“ section of “Get Started with Vungle - Android SDK“ to add the necessary frameworks.
- If you need to set Multidex , Proguard and Google Play Services, follow the instructions in the “Advanced Settings“ section of “Get Started with Vungle - Android SDK“ to update AndroidManifest.xml in your project.
- Call the MoPubInterstitial’s
show
method (or, for rewarded ads, call the MoPubRewardedVideos'sshowRewardedVideo
method) when you want to present a Vungle video ad. (No need to call the Vungle Android SDK methods directly. The MoPub SDK will do it.)
Configuration Options (Optional)
Interstitial Ads
Attribute |
Default Value |
Description |
SOUND_ENABLED_KEY |
true |
Play ad with sound muted or unmuted. Set to 'false' to play muted. Set to 'true' to play with sound. |
ORDINAL_VIEW_COUNT_KEY |
null |
If you receive ordinal data reports from Vungle, use this field to pass the mediation ordinal. This is an integer indicating the order in which this ad was shown in the game session (for example, if two ads were already shown in this session, and this ad from Vungle was then shown third, pass in '3'). Read more about ordinal data here. |
FLEX_VIEW_CLOSE_TIME_KEY |
null |
This the the amount of seconds the flex view videos will play before they automatically close. |
Example
ashMap<String, Object> extras = new HashMap<>();
extras.put(VungleInterstitial.SOUND_ENABLED_KEY, false);
extras.put(VungleInterstitial.ORDINAL_VIEW_COUNT_KEY, 1);
extras.put(VungleInterstitial.FLEX_VIEW_CLOSE_TIME_KEY, 5);
mMoPubInterstitial.setLocalExtras(extras);
mMoPubInterstitial.load();
Rewarded Ads
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. |
|
"Closing this video early will prevent you from earning your reward. Are you sure?" |
Sets the body of the confirmation dialog when skipping an incentivized ad. |
|
“Close Video” |
Sets the 'cancel button' text of the confirmation dialog when skipping an incentivized ad. |
|
“Keep Watching” |
Sets the 'keep watching button' text of the confirmation dialog when skipping an incentivized ad. |
|
“Close Video?” |
Sets the title of the confirmation dialog when skipping an incentivized ad. |
|
true |
Sets the starting sound state for the ad. If 'true', the audio respects device volume and sound settings. If 'false', video begins muted but user may modify. |
|
null |
If you receive ordinal data reports from Vungle, use this field to pass the mediation ordinal. This is an integer indicating the order in which this ad was shown in the game session (for example, if two ads were already shown in this session, and this ad from Vungle was then shown third, pass in '3'). Read more about ordinal data here. |
Example
public class MainActivity extends Activity {
@Override
MoPubRewardedVideos.initializeRewardedVideo(this, new VungleRewardedVideo.VungleMediationSettings.Builder()
.withUserId("VUNGLE_TEST_USER")
.withCancelDialogTitle("TITLE")
.withCancelDialogBody("BODY")
.withCancelDialogCloseButton("CLOSE")
.withCancelDialogKeepWatchingButton("CONTINUE")
.withSoundEnabled(false)
.withOrdinalViewCount(10)
.build()
);
MoPub.onCreate(this);
// ...
}
Additional Note
Android SDK - Hardware Acceleration
Hardware acceleration is enabled by default if your target API level is set to 14 or above. This option must be enabled for the SDK to properly show Dynamic Template ads. Please make sure your project does not have this option set to false.
< application android:hardwareAccelerated="true" ... >
Comments