# SDK Downloading and Integration

# Getting Started

Mint Mediation SDK supports the Android version 4.1 (API level 16) and above. Ensure that:

  • Android Studio 2.0 and above
  • Target Android API level 28 and above
  • MinSdkVersion level 16 and above

WARNING

Warning: in Mint Mediation Android SDK, the Adapter module for the third-party platform is packaged in a separate AAR file, and each platform provides a corresponding Adapter package.If you use the aggregation function of Mint Mediation SDK, do not forget to integrate the Adapter into the project.Please refer to our guidebook Add Intermediary Network.

# Overview

This guide describes how to integrate the Mint Mediation SDK into your Android app.

Mint Mediation is committed to providing the diversified and competitive ad aggregation and realization solution, which supports rich ad types, such as Rewarded Video, Interstitial, Native Ads and Banners. The Mint Mediation aggregation platform supports the domestic and foreign mainstream ad network interfaces, such as AdMob, Facebook, Mint Ad, UnityAds, Vungle, Tapjoy, AppLovin, AdColony, Chartboost, TikTok and MoPub, to help developers to achieve "one access and full coverage".

The newly designed Mint Mediation SDK provides the intelligent inventory mechanism and automatic ad loading/preloading mechanism, and it is committed to providing the best aggregation solution for app developers. With the Mint Mediation SDK, developers do not need to manually call the loadAd method of Rewarded Video and Interstitial to cache ads. SDK will automatically preload and cache ads. Furthermore, The inventory mechanism of multiple ads cache increases the availability of ads greatly.Therefore, the API interface of Mint Mediation SDK will be easier to use. Developers only need to check the ad inventory and present the ads in the scenes designed by the app.Developers can pay more attention to the app logic itself without taking time and effort on the loading and cache of ads.

# Application Ads ID

Before integration of Mint Mediation SDK, you need to get a developer account in the foreground of Mint Mediation Publisher, and then register your app and create the ad placement to get the necessary information for integration: APP_KEY and Placement ID.Developers access the foreground of Mint Mediation.

APP_KEY

APP_KEY is the unique identification assigned to the developer app. You can create an APP in the developer's foreground to get APP_KEY: Log in to enter the menu APPS ->, select 'View All Apps' ->, find APP in the list, and click 'Copy Chart' to copy it to the clipboard automatically.

Placement ID

Placement ID is the unique identification of ad placement.Developers can create more than one ad placement, and enter the menu APPS ->Placements to view all ad placement information. Mint Mediation supports Rewarded Video, Interstitial, Native Ads and Banners.

# Add SDK to Project

Mint Mediation SDK provides the online integration of Gradle dependencies.

Firstly, ensure that mavenCentral() is referenced in the allprojects part of the project level build.gradle file.

allprojects {
    repositories {
        mavenCentral()
    }
}

Next, open the dependencies part of the app level build.gradle file in your app to add the following codes.

dependencies {
    implementation 'com.mi.dev.mint:mint-mediation-sdk:1.9.10.0'
    implementation 'com.mi.dev.mint:mint-ad-adapter:3.1.3.0.1.9.10.0'
    implementation 'com.mi.dev.mint:mint-ad-sdk:3.1.3.0@aar'
    implementation 'com.squareup.okhttp3:okhttp:3.12.12'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.12.12'
    implementation 'com.google.android.gms:play-services-base:18.0.1'
    implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
}

# Updating AndroidManifest.xml Configuration

Next, you need to configure your AndroidManifest.xml file, add the permission script to <code><manifest> as shown below, and ensure that it is not put in <app>.

<!-- Required permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

# ProGuard

If you use ProGuard to protect your code in your app, add the following configuration to your ProGuard Configuration File (Android Studio: proguard-rules.pro or Eclipse: proguard-project.txt). Otherwise, SDK will report an error.

-dontwarn com.zeus.gmc.sdk.mobileads.mintmediation.**.*
-dontskipnonpubliclibraryclasses
# Mint Mediation
-keep class com.zeus.gmc.sdk.mobileads.mintmediation.**{*;}
-keep class com.zeus.gmc.sdk.mobileads.mintmediation.adapters.**{*;}
#R
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepattributes *Annotation*,InnerClasses
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
-keep class com.zeus.gmc.sdk.mobileads.columbus.** {*;}
-keep class com.zeus.gmc.sdk.mobileads.mintmediation.testsuite.** { *; }

# MultiDex

If you use MultiDex in your app, you need to add the following scripts to the build.gradle file.

android {
  buildTypes {
    release {
      multiDexKeepProguard file('multidex-config.pro')
      ...
    }
  }
}

The corresponding multidex-config.pro file is configured as follows:

-keep class com.zeus.gmc.sdk.mobileads.mintmediation.**{*;}
-keep class com.zeus.gmc.sdk.mobileads.mintmediation.adapters.**{*;} 

# Initializing

Before you call SDK to load and present ads, you need to initialize SDK firstly.We recommend that you initialize SDK when the app is started. For example, the onCreate() event method of activity is a good choice as shown below:

public class DemoActivity extends Activity {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      String appKey = "Your AppKey";
      // Please set GDPRConsent before init. If APP does not allow the personalized ads, set GDPRConsent to "false".
      MintAds.setGDPRConsent(true);
      MintAds.init(this, appKey, new InitCallback() {

         @Override
          public void onSuccess() {
              // Triggered when initialization is successful
          }

          @Override
          public void onError(Error error) {
              // Triggered when initialization fails
          }
      });
    }
}

WARNING

Warning: Call the MintAds.setGDPRConsent(Boolean allowPersonalizedAds) method before you call the init method. Otherwise, Mint Mediation SDK will not request the initialization.

WARNING

Warning: APP KEY is obtained when the app is created in the foreground of Mint Mediation.
Activity  is a required parameter, and Mint Mediation and other third-parties require an effective activity object for initialization, loading and presentation of ads. Do not use a temporary activity object, such as open screen interface of app. Otherwise, it will cause unknown exceptions.
We recommend that you call the loadAd method to load ads for the first time in the onSuccess callback event.
For Rewarded Video and Interstitial, you do not need to call the loadAd method to load ads, and SDK will load and preload ads automatically.
The error parameter of onError callback method contains the cause of initialization failure. In case of exception, please refer to Error Code for more information.

Best Practice: Initialization on Demand

Mint Mediation SDK provides a new initialization scheme, and you can specify one or more ad types for initialization.We recommend that you use this new method for initialization. The initialization method by ad type will preload the specified type of ads only.Based on this method, developers can initialize and preload different types of ads on different time nodes of app. For example, based on the ad scene design of app, the homepage ads are initialized when the app starts to get ads as soon as possible, while other types of ads can be initialized later.The advantage of this scheme is that it can disperse the ad preloading action that is originally concentrated on the time point of app starting to different time points, so as to avoid the slow ad loading due to the possible network congestion, which will affect the app experience.

The following code example demonstrates how to only initialize and preload Rewarded Video and Interstitial through the new initialization method.

/**
*The ad type parameter must be specified by the enumeration variable MintAds.Ad_Unit.AdUnitName, such as:
*/
MintAds.init(this, appkey, mcallback, MintAds.PRELOAD_AD_TYPE.INTERSTITIAL, MintAds.PRELOAD_AD_TYPE.REWARDED_VIDEO);

When you use the new initialization method, you can initialize each ad type at different time points of app as shown below:

// Initialize and preload Rewarded Video
MintAds.init(this, appkey, mcallback, MintAds.PRELOAD_AD_TYPE.REWARDED_VIDEO); 
// Initialize and preload Interstitial
MintAds.init(this, appkey, mcallback, MintAds.PRELOAD_AD_TYPE.INTERSTITIAL);  

Channel Initialization

// Indicate the incoming channel.
MintAds.init(this, appkey, channel, mcallback);  

Implementation of Callback Method

Mint Mediation SDK will trigger a series of events to inform the app during initialization. You need to implement the onSuccess() and onError() callback methods of the InitCallback interface to handle the initialization success and failure events.

@Override
public void onSuccess() {
    // Add code to handle the initialization success event.
}
@Override
public void onError(Error error) {
    // Add code to handle the initialization failure event.
    // The error parameter contains specific error information.
}

WARNING

Warning: The error parameter in the onError() event contains the error information. Please refer to Error Code.

Recording Life Cycle of Activity

We recommend that you reload the onPause() and  onResume()  methods of each activity object, and add corresponding onResume and onPause calls of Mint Mediation to record the life cycle of activity.

protected void onResume() {
  super.onResume();
  MintAds.onResume(this);
} 
protected void onPause() {
  super.onPause();
  MintAds.onPause(this);
}