Android Project Setup

Android SDK Integration Steps

1. Dependencies

Recent changes: 

  • New! (2/3/2020) Our AppLovin and MoPub adapters now support Banner 320×50
  • New! (2/3/2020) Performance improvements to the core sdk
  • Updated our Criteo adapter with bug fix; still using their 3.2.2 sdk
  • Now supports Banner 300×250, 320×50, 728×90 (tablet)
  • Added new floor feature.  VPAID support, Auto pre-fetch.
  • Added Amazon Mobile Ads (vers. 5) to our mediation stack with floor support!
  • Added segments and A/B testing functionality.  New methods:
  • Chocolate.setCustomSegmentProperty(Context context, String key, String value)
  • Chocolate.setTotalInAppPurchases(Context context, float totalInAppPurchases)


Chocolate supports mediation of the following ad networks:
Demand Source Name SDK Version SDK Size/Footprint
Chocolate Core 2.8.14 300kb
AdColony 4.1.1 370kb
Amazon Mobile Ads 5.+ 580kb
AppLovin 9.8.4 300kb
Criteo 3.2.2 200kb
Facebook 4.99.3 680kb
AdMob and Google IMA (pre-roll)
  • Google IMA 3.11.2
  • Google play-services-ads 17.2.0
Mopub 5.8.0 400kb
TapJoy 12.2.1 680kb
UnityAds 3.4.0 470kb
Vungle 6.4.11 280kb
Yahoo/Flurry 10.0.0 400kb
Total Added Footprint for all above partners including the Google Play Services Ads and Android Support Libraries: 4.1mb after building a final release APK. There are some common shared code in the above partners.
Note: Google Play Services Ads and Android Support Libraries would be required for any ads mediation platform and are at least 1mb in size.


2. Add dependencies and other settings to your app ‘build.gradle’
android {

    defaultConfig {

        // ... existing settings ...

        multiDexEnabled true

    compileOptions { 

        sourceCompatibility JavaVersion.VERSION_1_8 
        targetCompatibility JavaVersion.VERSION_1_8 



repositories {
    maven { url '' }
    maven { url "" }
    maven { url '' }
    // If you're using a version of Gradle greater than or equal to 4.1, you must use:

    // If you're using a version of Gradle lower than 4.1, you must use:
    maven { url '' }

    flatDir {
        dirs 'libs'

Within the dependencies section, merge in the following block:

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation ''
implementation ''
implementation ''
implementation ''
implementation 'com.applovin:applovin-sdk:9.8.4'
implementation ''
implementation ''
implementation '' //11.0.4 minimum is required, 16.0.0 or newer recommended! 
implementation('') {
   exclude group: ''
   exclude group: '', module: 'gson'

implementation ''
implementation('') {
   exclude group: ''
   exclude group: ''
   exclude group: ''

implementation ''
implementation 'com.tapjoy:tapjoy-android-sdk:12.2.1@aar'
implementation '' 
implementation ''
implementation('com.github.vungle:vungle-android-sdk:6.4.11') {
   exclude group: ''
implementation ''
implementation('com.mopub:mopub-sdk:5.8.0@aar') {
   transitive = true
   exclude group: ''
//Note: if you are using Pre-roll, un-comment the following line:
//implementation ''

//You do not have to use support library version 28.0.0, however, whichever version you do use
//must be the same throughout this gradle file.  This does not apply to multidex.
//Do not use '+' wildcards in the android support library version.
implementation ""
implementation ""
implementation ""
implementation ""
implementation ''


PROGUARD: If you use proguard, then copy the contents of our and append to your proguard file.


3. Modify your AndroidManifest.xml

Make sure tools is added to the manifest tag (com.mypackage is just an example):

<manifest package="com.mypackage"


   <meta-data android:name="" android:value="@integer/google_play_services_version"/>

   <!-- If using Google Ads 17 or higher, we must include: -->
   <!-- Use this value until Chocolate provides the official one. -->
   <meta-data tools:replace="android:value"


Declare the following permissions outside the application tag.

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

<!-- NOTE: We do NOT require the following permissions! -->
<!-- So, we are removing them below.  Unless your application needs them. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" tools:node="remove" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" /> 
<uses-permission android:name="android.permission.SEND_SMS" tools:node="remove" /> 
<uses-permission android:name="android.permission.CALL_PHONE" tools:node="remove" /> 
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" /> 
<uses-permission android:name="android.permission.READ_CALENDAR" tools:node="remove" /> 
<uses-permission android:name="android.permission.WRITE_CALENDAR" tools:node="remove" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:node="remove" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" tools:node="remove" />


4. GDPR Support

The Chocolate Ads SDK is GDPR-ready and supports the IAB Standards for GDPR compliance.

Use the following simple api in conjunction with your existing Consent Management Provider.  If you do not have a CMP solution, that’s ok, too!  Our mediation sdk will detect if the user is in the EU and automatically apply GDPR actions to the ad request.  So, by default, you do not have to do any extra work to use our sdk in a GDPR-compliant fashion.

/* Save consent string */
Chocolate.setGDPR(Context context, boolean isSubjectToGDPR, String iabConsentString);

/* Indicates if the device is subject to GDPR by checking device locale.  No network required! */
Chocolate.isSubjectToGDPR(Context context);


5. Initializing Chocolate

In native Android apps, please initialize the Chocolate Ads SDK:

In your main Activity, call Chocolate.initNote: please use the Activity context as some of our mediation partners sdk require Activity.  Do not pass the application context.

public class MyActivity extends AppCompatActivity {

    private static final String API_KEY = "XqjhRR";   //Feel free to use as a test key until you get your own!
    private LVDOAdRequest adRequest;

    protected void onCreate(Bundle savedInstanceState) {

        adRequest = new LVDOAdRequest(this);

        //Be sure to set these values before going live.
        adRequest.setRequester("Chocolate Demo Company");
        adRequest.setAppName("Chocolate Demo");

        Chocolate.init(this, API_KEY, adRequest, new InitCallback() {
            public void onSuccess() {
                //Do not fetch ad here; we will do it for you automatically.

            public void onError(String initError) {




Note on Background Fetch

Chocolate Android SDK runs some background fetch (using JobIntentService) in an effort to make sure that we will have ads available by the time user is ready to see an ad.


Now we are ready to implement the ad units (easy).  If you have already implemented the ad units, then you may build and run, manage in Android Studio.