Integration Steps - Unity Plug-In for Android


With Chocolate Mediation SDK Unity Plug-in, you can enable Full Screen Interstitial and/or Rewarded Video Ad Units in your Unity game. Our SDK is also GDPR compliant.

Total Added Footprint for all above partners including the Google Play Services Ads and Android Support Libraries: 4.3mb after building a final release APK.


Integration Steps

Note: Our integration steps have changed. Please read these instructions carefully.

1. Download our Chocolate Ads Mediation Unity Package:

ChocolateMediationPlugin-1.0.6.unitypackage (New!)

Import it as a Custom Unity Package:

Note: If you are currently using VdopiaListener.cs (Old) and VdopiaPlugin.cs (Old) in your project from a previous integration, please remove those. If you had a previous version of ChocolateUnityBridge.cs and VdopiaAndroidListener.cs you can remove those as well. The new unity package places the new scripts in the Assets/ChocolateMediation folder.


2. Integrating Full Screen Interstitial and Rewarded Video Ad Units

Refer to code sample below. The flow is easy; allow a few seconds for the sdk to initialize. Then, call loadRewardAd (or loadInterstitialAd) and wait for the callbacks. Implement the callback interfaces. Un-register callback listeners when necessary. That’s it.

See Unity Code Sample

We also supplied a sample scene ChocolateAdsSampleScene.unity and the corresponding script SampleChocolateAds.cs which displays the ad when you click on the load ad button.

3. Building the Android App

Note:  If you are using older Unity 5.x, please skip to Export below.

If you are using Unity 2017, or 2018+ then continue as follows…

This is where you will configure your Unity project for building Android app.

In Unity, open ‘Build Settings’. Choose ANDROID.  Do not build until all the steps have been completed.

From ‘Build Settings’ click on ‘Player Settings’. Then, choose ‘Publishing Settings’. Make sure to check Custom Gradle Template. Unity will create: Assets/Plugins/Android/mainTemplate.gradle which you will edit soon.

You don’t need to use ‘Minify’ or ‘proguard’. However, if you want to use these, there is a section towards the end about this topic.

In ‘Other Settings’ under Player Settings, make sure Minimum API level is 17. The Target API level should be ‘Automatic (highest installed)’.

Install Advertisement Version 3.0.3 or Greater (Advertisement 3.4.0 recommended)

Unity → Window → Package Manager

Our Chocolate/Unity Ads adapter depends on Unity Ads Package 3.0.3 (or greater) to be installed via the Package Manager. Please make sure this is reflected as follows, otherwise the game will crash with “ClassNotFoundException UnityAdsListener”.

Please install the latest version of Unity Ads Package.


4. Edit mainTemplate.gradle & AndroidManifest.xml

If you are using Unity 5.x or lower and you have exported your Unity project to a separate Android project, you will be editing build.gradle and AndroidManifest.xml following the instructions in this step.

If you are using a newer version of Unity (2017, 2018 or higher), open Assets/Plugins/Android/mainTemplate.gradle in your file editor.

First, remove the following line at the top of the file:



Continue editing…

android {

   defaultConfig {
      // ... other existing settings ...
      multiDexEnabled true



repositories {
    maven { url '' }
    maven { url "" }
    maven { url '' }



Within the dependencies section (ROOT LEVEL), merge in the following block. This ‘dependencies’ section should already contain the line:

implementation fileTree(dir: ‘libs’, include: [‘*.jar’])

If it does not contain that line, then it is not the correct ‘dependencies’ section and you must find the correct one.

implementation ''
implementation ''
implementation ''
implementation ''
implementation ''
implementation 'com.applovin:applovin-sdk:9.8.4'
implementation ''
implementation('') {
  exclude group: ''
  exclude group: '', module: 'gson'
implementation ''
implementation 'com.tapjoy:tapjoy-android-sdk:12.2.1@aar'
implementation ''
implementation ''
implementation ''
implementation('com.github.vungle:vungle-android-sdk:6.4.11') {
  exclude group: ''

  //Note: If you already have gson2.x.jar in your Android folder then you need to exclude as follows.
  //Otherwise, you will get Multidex build error.

  // exclude group: '', module: 'gson'
implementation ''



5. Play Services Resolver

After you have made the changes to mainTemplate.gradle, check Resolver Settings under Assets file menu:

Resolver Settings

If there is an option to Use Jetifier, please make sure it is Not Checked. Hit OK.

If you do not see this option, then just close the Resolver Settings dialog.

Now, you may resolve dependencies via Assets file menu:

If resolution was successful, you should see:

Note: If you have previously integrated Chocolate and had to manually copy in the following files to the Android folder, you may not need them anymore. The Play Services Resolver may actually remove them after you click resolve.


Continue editing mainTemplate.gradle …


Android Gradle Version

Find the following line:

classpath ''

And notice the version. If your android gradle version is 2.3.X or lower, then you must replace keyword implementation with the compile keyword. If greater or equal to 3.0.X, then we are fine.


6. Finally, download our AndroidManifest.xml

and copy it to folder: YOUR_UNITY_PROJECT/Assets/Plugins/Android 



If you want to use Minify and Proguard, check User Proguard. proguard-user.txt will be generated in the Android folder. Append the contents with our proguard settings..

If you choose not to use Minify with Proguard, then choose None for Minify release and debug and uncheck User Proguard checkbox.
YAY!  Now, you may BUILD the Android app. Click on the BUILD button from Build Settings in Unity. This will produce the signed APK file that you can release to the Google Play Store or install and run on an Android device.

If you have an Android device connected to your computer, you may click on BUILD AND RUN.


Exporting to Android Studio

If you are using an older version of Unity (such as 5.x or earlier) OR if you prefer to have more control over your Android app, you may choose to export the project to Android Studio.

Install the latest Android Studio

  1. Complete the above Unity steps 1-3
  2. Open ‘Build Settings’, check the ‘Export Project’ checkbox and hit the ‘EXPORT’ button.
  3. Choose a folder where you wish to save your Android Studio project.  Then, open the project using Android Studio.
  4. Go to Edit Gradle and AndroidManifest.xml

After opening the project, Android Studio may show dialog notifications to update to the latest android gradle version. Please accept those requests.


How to turn on ads on your ad unit

Please send us your sample app with the integrated code. We will help you validate the SDK setup and turn on the demand.
Get started using our test key: "XqjhRR"

You can contact us via email: