Advanced Settings

Begin by following the instructions in the basic integration article, and then the instructions for any of the ad formats you want to integrate (interstitial or rewarded ads, banner ads, MREC ads). This article contains supplementary information and assumes you have completed basic integration. 

GDPR Recommended Implementation Instructions

As of May 25, 2019, the General Data Protection Regulation (GDPR) will be enforced in the European Union. To comply with GDPR, developers have two options.

  • Option 1 (recommended): Publisher controls the GDPR consent process at the user level, then communicates the user’s choice to Vungle. To do this, developers can collect the user’s consent using their own mechanism, and then use Vungle APIs to update or query the user’s consent status. Refer to the sample code below for details.
  • Option 2: Allow Vungle to handle the requirements. Vungle will display a consent dialog before playing an ad for a European user, and will remember the user’s consent or rejection for subsequent ads.

The updateConsentStatus method (recommended in Option 1) takes the user's consent status and the consent message version as its parameters.

public static void updateConsentStatus(@NonNull Consent status, @NonNull String consentMessageVersion)

The consent status will specify whether the user has OPTED_IN or OPTED_OUT for the message version you displayed. The consentMessageVersion specifies the publisher-controlled consent policy version; this enables you to pool your users by the message version and seek consent again when the GDPR policy changes.

// Usage example of GDPR API
// To set the user's consent status to opted in:
Vungle.updateConsentStatus(Vungle.Consent.OPTED_IN, “1.0.0”);

// To set the user's consent status to opted out:
Vungle.updateConsentStatus(Vungle.Consent.OPTED_OUT, “1.0.0”);

// To find out what the user's current consent status is:
// This will return null if the GDPR Consent status has not been set
// Otherwise, it will return Vungle.Consent.OPTED_IN or Vungle.Consent.OPTED_OUT
Vungle.Consent currentGDPRStatus = Vungle.getConsentStatus();
String consentMessageVersion = Vungle.getConsentMessageVersion();

CCPA Implementation

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

The updateCCPAStatus method takes the user's consent status to specify whether user has OPTED_IN or OPTED_OUT and getCCPAStatus() method returns current CCPA status for the user.

public static void updateCCPAStatus(@NonNull final Consent status)
public static Consent getCCPAStatus()
// Usage example of CCPA API
// To set the user's CCPA status to opted in:

// To set the user's CCPA status to opted out:

// To find out what the user's current consent status is:
Consent currentCCPAStatus = Vungle.getCCPAStatus();

Restrict Use of Device ID

Starting with Vungle Android SDK v6.4.11, you can now restrict the transmission of the Android ID used when the Google Advertising ID is not available.

// Set true to opt out for Android ID collection by SDK or false (default) to opt in
VungleSettings vungleSettings = new VungleSettings.Builder()
Vungle.init(appId, getApplicationContext(), initCallback, vungleSettings);

Include Google Play Services

Including Google Play Services with your project is optional, but recommended. It enables Vungle to provide a more customized ad experience to your end user. We recommend that you include basement and ads-identifier APIs, and that you use version Google Play Services v11.0.1 or higher.

To include Google Play Services, refer to Google's setup guide. In your app, ensure that the device has a sufficiently updated version of Google Play Services. The Vungle SDK optionally uses the location and ads API from Google Play Services.

  • (Recommended)
  • (Required for AAID)

Method Count Reduction

Adding Vungle Android SDK v6 to your project adds approximately 700 core Vungle methods, excluding any transitive dependencies. A full integration including third-party libraries is expected to add less than 4000 methods on average. Consider the following suggestions to reduce the total number of methods added to your project:

  • ProGuard: You can enable ProGuard to shrink your project code. It will discard any unused classes at the time of compilation to make the total method count as small as possible. You can enable it by setting minifyEnabled to true in build.gradle for the appropriate build type, and by providing the rules to keep the classes required by your project.
  • MultiDex: If you are still above a 65K method count, enabling MultiDex may be the only solution provided by Google. You must only configure your project to MultiDex one time, but it will have an impact on build and app startup time.


If you are using ProGuard, add the following rules to your ProGuard configuration file:

# Vungle
# Vungle
-dontwarn com.vungle.warren.downloader.DownloadRequestMediator$Status
-dontwarn com.vungle.warren.error.VungleError$ErrorCode

# Google

# Moat SDK
-keep class com.moat.** { *; }
-dontwarn com.moat.**

-keepattributes *Annotation*
-keepattributes Signature
# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * { <fields>;

# OkHttp + Okio
-dontwarn javax.annotation.**
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-dontwarn org.codehaus.mojo.animal_sniffer.*
-dontwarn okhttp3.internal.platform.ConscryptPlatform

Set Minimum Disk Space

Minimum disk space configuration was introduced in Vungle SDK v6.4.11 to determine the limits for available space on a user’s device before the Vungle SDK initializes and fetches ads. The default value for setMinimumSpaceForInit is 51 MB and setMinimumSpaceForAd is 50 MB. The size is entered in bytes.

VungleSettings vungleSettings = new VungleSettings.Builder()
    .setMinimumSpaceForInit(51L * 1024L * 1024L)  // 51 MB
    .setMinimumSpaceForAd(50L * 1024L * 1024L)    // 50 MB
Vungle.init(appId, getApplicationContext(), initCallback, vungleSettings);

Hardware Acceleration

Hardware acceleration is enabled by default for your application if your target API level is set to 14 or above. This option must be enabled for the SDK to properly show Dynamic Template and MREC ads. Make sure this option is set to 'true' at the application level of your project:

<application android:hardwareAccelerated="true" ...>

Retrieve the SDK Version Number

To programmatically retrieve the SDK version number at runtime (this useful in internal mediation), Vungle provides the following String:


Exception Codes for Debugging

InitCallback, PlayAdCallback, and LoadAdCallback will have a VungleException code when the onError callback fires. You can use the code to debug or take actions to correct the issue programmatically.

if (exception.getExceptionCode() == VungleException.VUNGLE_NOT_INTIALIZED) {
  // Call routine to initialize SDK
Exception Code Description
CONFIGURATION_ERROR A configuration error occurred. Check your app ID and placement reference IDs, and try again when network connectivity is available.
NO_SERVE Ad server found no advertisements for your current bid. Please try again later. This exception is expected behavior.
UNKNOWN_ERROR An unknown error occurred. This exception should be rare.
AD_EXPIRED The advertisement in the cache has expired and can no longer be played. Please load another ad.
MISSING_REQUIRED_ARGUMENTS_FOR_INIT Please ensure all parameters for Vungle.init() marked as NonNull are provided, as they are essential for the SDK to function.
APPLICATION_CONTEXT_REQUIRED Please provide the application Context so that our SDK can continue to support our API beyond the Activity lifecycle.
OPERATION_ONGOING There is already an ongoing operation for the action you requested. Please wait until the operation completes before starting another.
VUNGLE_NOT_INTIALIZED Vungle is not initialized, or no longer initialized. Please call Vungle.init() to reinitialize.
AD_UNABLE_TO_PLAY Unable to play advertisement.
AD_FAILED_TO_DOWNLOAD Advertisement failed to download.
PLACEMENT_NOT_FOUND Placement is not valid.
SERVER_RETRY_ERROR Remote server responded with HTTP Retry-After, the SDK will retry this request.

Configure Auto Backup for JAR Integration

The "allow backup" setting is enabled by default for your application for API 23 or higher. The backup rule ensures that all application data is backed up for proper operation of the Vungle SDK and of the app itself. If you have not disabled the "allow backup" setting or specified your own backup rules, you must provide additional XML rules to define which files in our SDK file system should be excluded from automatic backup.

Vungle Exclusion Rules

    <exclude domain="file" path="vungle" />
    <exclude domain="file" path="vungle_cache" />
    <exclude domain="external" path="vungle_cache" />
    <exclude domain="database" path="vungle_db" />
    <exclude domain="sharedpref" path="com.vungle.sdk.xml" />

Gradle Integration with Developer Backup Rules

  1. Add Vungle SDK exclusion rules to the existing .xml file that has your app’s own exclusion rules.
  2. Configure fullBackupContent to be replaced on the application level and add the Vungle SDK exclusion rule to the existing .xml.

JAR Integration with Developer Backup Rules

  1. Create a new XML file with Vungle exclusion rules.
  2. Place the .xml file under the res/xml directory.
  3. Add fullBackupContent in the application tag of AndroidManifest.xml with the file name of the .xml file you created above.

Disable Auto Backup

If backup is not required for your app, you can simply disable it on the application tag:

    android:allowBackup="false" >

List of Valid Placements

We provide a helper method that returns a Collection of Strings containing all valid Placement Reference IDs for the current session.

public static Collection getValidPlacements()
Powered by Creativity Driven by Performance Sign Up Here


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

Was this article helpful?