Skip to main content
Version: 4.x.x

Getting Started

Overview

BlueStack-SDK 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.

Prerequisites

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 settings.gradle of your project, you must declare there repositories :

dependencyResolutionManagement {
...
repositories {
...
google()
mavenCentral()
...
}
...
}

2) Add the following dependency to your app's build.gradle, and make sure the latest SDK is used:

Mandatory :

  • Bluestack Mediation SDK
dependencies {
// Bluestack SDK
implementation 'com.azerion:bluestack-sdk-core:4.4.0'
}

Note : BlueStack SDK is compatible with any official IAB licensed CMP

Make your application comply with the new General Data Protection Regulation (GDPR) law applies in Europe.

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

<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="com.google.android.gms.permission.AD_ID" />

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{
@Override
public void onCreate() {
super.onCreate();
MNGAdsFactory.initialize(this, "YOUR_APP_ID");
}
}

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() {
@Override
public void onMNGAdsSDKFactoryDidFinishInitializing() {
Log.d(TAG, "MNGAds SDK Factory Did Finish Initializing");
}

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

@Override
public void onMNGAdsSDKFactoryAdapterInitializationStatus(BlueStackInitializationStatus blueStackInitializationStatus) {
for (BlueStackAdapterStatus adapterStatus : blueStackInitializationStatus.getAdapterStatus()) {
Log.d(TAG, "name: " + adapterStatus.getProvider() + " state: " + adapterStatus.getState() + " description: " + adapterStatus.getDescriptionStatus());
}
}
});

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.

Troubleshooting

Enabling debug mode

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

...
MNGAdsFactory.setDebugModeEnabled(true);
...

CompileOptions

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

android {
// …

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}

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 :

buildTypes
{
packagingOptions {
exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties'
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/pom.properties'
}
}

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.8.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:1.8.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"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</base-config>
</network-security-config>

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:

<application
android:name=".MyApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config">
</application>

Select an ad format

MNG SDK offers a number of different ad formats :