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();

COPPA Implementation

Generally speaking, the Children’s Online Privacy Protection Act (COPPA) regulates the collection, use, and disclosure of personal information for children under the age of 13 by certain websites and online services (including mobile apps). Compliance with COPPA is a legal issue and we suggest you seek the advice of an attorney in determining compliance. Additionally, for more information on COPPA, please refer to the Federal Trade Commission's COPPA FAQ.

Vungle has tools to assist publishers with COPPA compliance. In addition to use of settings on the Vungle Publisher Dashboard, Vungle now offers features within the Vungle SDK using the new COPPA API.

Set COPPA Compliance At the Device Level

Previously, Vungle offered COPPA assistance with settings only at the app level or the placement level. This meant that, where enabled, a publisher had to globally treat all traffic for a given app or placement as subject to COPPA or not. Enablement (or non-enablement) of these Vungle dashboard settings may work well for apps that clearly are (or clearly are not) directed to children under 13.

However, starting with SDK v.6.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 COPPA API is therefore most appropriate in cases of apps that legally can implement an age screen or age gate in accordance with COPPA rather than treating all users under 13. If you believe your app as a whole is primarily directed to children under the age of 13 as set forth in COPPA and related guidance, the COPPA dashboard settings are more appropriate for you.

To beta-test the COPPA API, please contact Vungle Support at tech-support@vungle.com.

Recommendations for Using Vungle’s COPPA Compliance Tools

Pursuant to the Vungle SDK License and Publisher Terms, it is the publisher’s responsibility to ensure compliance with applicable laws, including COPPA. Vungle is not liable for COPPA violations resulting from incorrect settings communicated via the COPPA API. Consider the following recommendations to help you ensure COPPA compliance:

  1. Consider using the COPPA API if you have confirmed you are a “mixed-audience app” under COPPA and are permitted to and have implemented an age gate or age screen: As noted above, in addition to using the new COPPA API in this latest SDK release, you can establish COPPA settings at the app or placement level on the Publisher Dashboard. However, under the current release of the COPPA API functionality, in the event of a conflict between the Publisher Dashboard and COPPA API settings, the COPPA API settings take precedence. For example, if COPPA settings on the Publisher Dashboard are enabled for a given app, but then the same app also enables use of the COPPA API and identifies a given user as over 13, Vungle’s SDK will treat this as you representing and warranting that you have COPPA compliant consent, a COPPA exception to consent, or you can otherwise treat the user in this app as above the age of 13. We therefore strongly recommend only using the COPPA API if you are a mixed-audience app with an age gate or age screen.
  2. Dashboard vs. COPPA API: In cases where it is clearer whether or not your app is primarily directed to children under the age of 13, we recommend using the COPPA settings section in the Publisher Dashboard instead of the COPPA API.

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
-dontwarn com.vungle.warren.downloader.DownloadRequestMediator$Status
-dontwarn com.vungle.warren.error.VungleError$ErrorCode

# Google
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**

# 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

-dontwarn module-info

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?