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. getConsentStatus may return null until updateConsentStatus has been called or users make their consent using Vungle consent dialog.

// 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.

In accordance with CCPA, the consent status is opted in by default unless updateCCPAStatus has been explicitly called to set it as opted out. getCCPAStatus may return null if not set but will be treated as opted-in.

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:
Vungle.updateCCPAStatus(Consent.OPTED_IN);

// To set the user's CCPA status to opted out:
Vungle.updateCCPAStatus(Consent.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()
    .setAndroidIdOptOut(true)
    .build();
    
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.

  • google.android.gms:play-services-basement:17.6.0 (Recommended)
  • google.android.gms:play-services-ads-identifier:17.0.0 (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.

ProGuard

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
-dontwarn com.google.android.gms.common.GoogleApiAvailabilityLight
-dontwarn com.google.android.gms.ads.identifier.AdvertisingIdClient
-dontwarn com.google.android.gms.ads.identifier.AdvertisingIdClient$Info

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

# GSON
-keepattributes *Annotation*
-keepattributes Signature
# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
  @com.google.gson.annotations.SerializedName <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
    .build();
  
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:

com.vungle.warren.BuildConfig.VERSION_NAME

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 the routine to initialize Vungle 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.

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

Questions?

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

Was this article helpful?