Clone wiki

mngads-demo-android / setup

Android SDK Integration


MNG Ads provides functionalities for monetizing your mobile application: from premium sales with rich media, video and innovative formats, it facilitates inserting native mobile ads as well all standard display formats.

You can see : Our Sample, Change Log and Upgrade Guide.


Before You Start, MNG Ads requires minimum :

  • Android 4.4 (API level 19) or higher.
  • CompileSdkVersion at least 31.
  • Android Studio 4.0 or higher.

Step 1. Installation using Gradle

1) In the main build.gradle of your project, you must declare there repositories :

repositories {

    //For SmartAdServer configuration 
    maven {  
    url ''  

    // Optional: Huawei services dependencies repository
    maven { url '' }

    //For Ogury configuration
      maven {
        url ''

    // For All Bluestack SDKs (Mediation, CMP, Location)
         username "madvertise-maven"
         password "GpdGZ9GE9SK7ByWdM987"
     url ""

      // For Sync SDK 
    maven {
             url ''
            credentials {
                username "guestsync"
                password "ELn3qwzMCWmJcawgHdqM"
            authentication {

2) Include JCenter/Maven repository and add the following lines to your app's build.gradle, and make sure the latest SDK is used:

Mandatory :

  • Google play services
dependencies {
//Google Ads SDK
implementation ''
  • Bluestack Mediation SDK
dependencies {
// Bluestack SDK
implementation 'com.madvertise:bluestack-core-sdk:4.1.2'

Recommended :

  • Google Ads SDK
  • AudienceNetwork
  • SmartAdServer (Note : It available as in-App Bidding Bidder)
dependencies {
//Google Advertising Id
implementation ''

//Google Ads SDK
implementation ''
implementation ''

//Location, if you app use GPS data only with a CMP
implementation ''

//Audience Network SDK
implementation ''

//Smart Display SDK
implementation ''
// Optional : add Smart support library for Huawei devices
implementation ''

Make your application comply with the new General Data Protection Regulation (GDPR) law applies in Europe. (for additional information please visit our website)

This SDK works with our MAdvertise CMP only for The GDPR rules. (for additional information please visit our website)

Recommended in-App Bidding :

  • Amazon APS
  • Criteo
dependencies {
// Amazon SDK
implementation ("")

// Criteo SDK
implementation 'com.criteo.publisher:criteo-publisher-sdk:4.4.0'
implementation 'com.madvertise:bluestack-mediation-criteo:4.4.0'

Optional :

  • AdColony
  • Ogury (Note : An API Key will be assigned to your application by mngads support team for Ogury library.)
  • Sync

dependencies {  
// Adcolony SDK
implementation 'com.adcolony:sdk:4.6.4'
implementation 'com.madvertise:bluestack-mediation-adcolony:4.6.4'

//Ogury SDK
implementation 'co.ogury:ogury-sdk-no-data:5.3.0'
implementation 'com.madvertise:bluestack-mediation-ogury:5.3.0'

//Sync SDK
implementation 'tv.sync:syncdisplay:3.2.1'
Support library for Huawei devices :

In the dependencies section of your application module build.gradle file, declare the BlueStack huawei support library dependency and the Huawei library:

//Huawei devices
implementation 'com.huawei.hms:ads-identifier:'
implementation 'com.madvertise:bluestack-mediation-huawei:1.0.1'

See our build.gradle sample

Step 2. Update AndroidManifest.xml

1) Manifest Permissions

Add the following permissions to your AndroidManifest.xml file inside the manifest tag but outside the <application> tag, if not done already:

    <!-- Grants the SDK permission to access approximate location based on cell tower. -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <!-- Grants the SDK permission to access a more accurate location based on GPS. -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <!-- External storage is used for pre-caching features if available -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <!--Used by Sync-->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <!--Used by AdColony-->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!--Used by AdColony-->
    <uses-permission android:name="android.permission.VIBRATE"
    <!--Grants the SDK permission to access the Ad Id,since android 12 and target 31-->
    <uses-permission android:name=""" />

2) Google Play Services

Add the following inside the <application> tag in your AndroidManifest , if not done already:


Step 3. Configuring the SDK

Init the SDK

You have to init the SDK in your application class

import com.mngads.MNGAdsFactory;
public class DemoApp extends Application{

public void onCreate() {

Verify Your Integration

To verify if the SDK is fully initialized, you have to implement the Factory Listener in your code:

MNGAdsFactory.setMNGAdsSDKFactoryListener(new MNGAdsSDKFactoryListener() {
            public void onMNGAdsSDKFactoryDidFinishInitializing() {
                Log.d(TAG, "MNGAds SDK Factory Did Finish Initializing");

            public void onMNGAdsSDKFactoryDidFailInitialization(Exception e) {
                Log.d(TAG, "MNGAdsSDKFactoryDidFailInitialization: " + e);

The SDK will notify your Listener of all possible events listed below :

  • onMNGAdsSDKFactoryDidFinishInitializing() is called when the initialisation finished or is already installed.

  • onMNGAdsSDKFactoryDidFailInitialization() is called when an error occurs during initialisation.


Enabling debug mode

To enbale debug mode you need to set debug mode to true :



You have to add compileOptions to your module's gradle file like so:

android {
    // …

    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8

OKHTTP issue

If you use okhhtp in your project or in an other dependency, add these lines in your build.gradle to avoid build error :

packagingOptions {
exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/'
exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.xml'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
exclude 'META-INF/maven/com.squareup.okio/okio/'

Android multidex issue

For more information, please see this AndroidMultidex

Include Kotlin to an existing app

Your build.gradle files should look similar to the examples below:

  • Add Kotlin to your project classpath :

Project build.gradle file

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20"
  • Applies the Kotlin Android plugin to each module that contains Kotlin files.

Module build.gradle file

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
dependencies {
   implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.20"

Network Security Configuration

Since Android 9 (API level 28), all network requests must use HTTPS protocol, basic HTTP requests will be blocked by default. To avoid your ads being blocked by the default network security configuration, you should create your own network security configuration XML file.

In your res folder, create the folder xml (if not created yet) then create a file named network-security-configuration.xml.

Your file must be formatted like this:

<?xml version="1.0" encoding="utf-8"?>
    <base-config cleartextTrafficPermitted="true">
            <certificates src="system" />
            <certificates src="user" />

Once the file created, make sure to add android:networkSecurityConfig="@xml/network_security_config" in the application tag of your AndroidManifest.xml file. For instance:


Select an ad format

MNG SDK offers a number of different ad formats :