Android SDK Integration

Before You Start

We support Android Operating Systems Version 4.1 (API Level 16) and above. Be sure to:

  • Use Android Studio 2.0 and above

  • Target Android API level 28

  • MinSdkVersion level 16 and above

Important! The ADAPTERS for ad networks are modularized as independent .aar files and should be downloaded as required by yourself. If you want to use AdTiming SDK to mediate networks, Be sure to follow our Add Mediation Networks and Mediation Integration Guides.


1. Overview

This Guideline introduces the integration of AdTiming's SDK in Android Apps.

AdTiming offers diversified and competent monetization services and supports a variety of Ad formats including Native Ad, Interstitial Ad, Banner Ad, and Rewarded Video Ad. The AdTiming platform mediates AdTiming, AdMob, Facebook, UnityAds, Vungle, Tapjoy, AppLovin, AdColony, Chartboost, MoPub, Pangle and IronSource.

New in Version 6.0 !

The newly designed AdTiming Mediation SDK (Version 6.0.0 and above), equipped with smart ad inventory mechanism and optimized SDK initialization pre-loading mechanism, provides the best mediation solution for app developers. For Rewarded Video, Interstitial and Interactive Ad, the SDK will cache ads automatically and maintain ad inventory regularly, such as pre-loading after initialization, loading after ad served and timing loading etc. You have no need to invoke load() method to cache ads by yourselves anymore with version 6.x.x. The new APIs are easier to use.

2. Ads ID

This section introduces how to fetch and use identity information when integrating the AdTiming SDK, including: APP_KEY, Placement ID, account and configurations of the mediation platform.

APP_KEY: APP_KEY is the sole identification of developer’s application on AdTiming platform. Developers need to create their Apps and obtain APP_KEY through the AdTiming Developer Platform.

  • Navigate to Apps -> Select 'Apps' -> Click on 'View All Apps'
  • Click on 'Copy' 

Placement ID: identifies the ads placement at Adtiming. Developers may create multiple ads placement on the AdTiming Developer Platform to meet their needs. The placement supports formats including BannerAd, InterstitialAd, NativeAd, VideoAd and InteractiveAd.



3. Add AdTiming SDK to your Project

AdTiming Supports both Gradle dependencies and manual download mechanisms to integrate our SDK.

Gradle dependencies

  • Add the following to your project-level build.gradle file inside repositories section.
allprojects { 
repositories {
 maven {
           url '
  • Add the following to your application-level build.gradle file inside dependencies section.
dependencies {
    implementation  'com.adtiming:mediation-sdk:6.6.1@aar'


Manual Download

1.  Download Android SDK Version 6.6.1

2. Add the SDK to Your Project

Unzip and add the AdTimingSDK-x.x.x.aar to the libs folder in your Android Project.

Make sure you add the following to your Gradle build file under the dependencies section:

implementation (name:'AdTimingSDK-x.x.x', ext:'aar')


AdTiming Mediation Demo App

The Integration Demo application demonstrate how to integrate the AdTiming Mediation in your app.

Download Android Demo Application


4. Update AndroidManifest.xml

Configure your AndroidManifest.xml to add the following permissions into the <manifest> tag but outside the <application> tag.

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


5. Proguard 

You must add the following to your Proguard configuration file (Android Studio: or Eclipse: proguard-project.txt) if you are using Porguard in your application. Failed to do so will lead to errors.

-dontwarn com.adtiming.mediationsdk.**.*
-dontwarn com.mopub.**.*
-dontwarn com.aiming.mdt.**.*
-keep class com.adtiming.mediationsdk.mediation.**{*;}
-keep class com.mopub.**{*;}
-keep class com.aiming.mdt.**{*;}
-keep class com.adtiming.mediationsdk.mobileads.**{*;}

-keepclassmembers class **.R$* {
   public static <fields>;
-keepattributes *Annotation*
-keepattributes InnerClasses
-keepnames class * implements android.os.Parcelable {
   public static final ** CREATOR;


6. MultiDex

If your project has a multDex operation,Add the following to your build.gradle file.

android {
  buildTypes {
    release {
      multiDexKeepProguard file('')

-keep class com.adtiming.mediationsdk.mediation.**{*;}
-keep class com.mopub.**{*;}
-keep class com.aiming.mdt.**{*;}
-keep class com.adtiming.mediationsdk.mobileads.**{*;}


7. Override Your Activity Lifecycle Methods

Override the onPause()onResume() methods in each of your activities to call the corresponding AdTiming methods as follows:

protected void onResume() {
protected void onPause() {


8. Initialization

Before you can fetch ads from AdTiming Mediation Platform, you should first initialize the Adtiming SDK when your app started. To do so, we suggest to call AdTiming SDK's init() method within onCreate() of an Activity as belows:

import com.adtiming.mediationsdk.AdTimingAds;
public class DemoActivity extends Activity {

   protected void onCreate(Bundle savedInstanceState) {
      String appKey = "Your AppKey";
      AdTimingAds.init(this, appKey, new InitCallback() {

          // Invoked when the initialization is successful.
          public void onSuccess() {

          // Invoked when the initialization is failed.
          public void onError(AdTimingError message) {


  • APP KEY can only be obtained by creating apps on AdTiming.
  • Activity is the  must-have parameter.  Do not use temporary Activity object as parameter that will due to UnknowException. See Error Code for more information.
  • We suggest that the first call to method loadAd after the app starts should be in the onSuccess callback.
  • No need to invoke loadAd method for Rewarded Video & Interstitial Ads anymore, the SDK will fetch Ads automatic and maintain the ad inventory.
  • The error parameter in onError callback describes the cause of failure. Check the  Error Code for more information and guidance on errors. 

Best Practise: Init the SDK with AdUnits

The SDK can be  initialized in another way and we recommend this approach as it will only fetch the specific ad units you define in the adUnits parameter. The adUnits parameter is a string array. The following illustrates that the SDK is initiated with Rewarded_Video&Interstitial AdUnits and only these two types Ads will be fetched automatic. 

*Ad Units should be in the type of AdTimingAds.AD_TYPE.AdUnitName, for example:
AdTimingAds.init(this, appkey, mcallback, AdTimingAds.AD_TYPE.INTERSTITIAL, AdTimingAds.AD_TYPE.REWARDED_VIDEO);

When using this init approach, you can initialize each ad unit separately at different touchpoints in your app flow in one session.

// Init with pre-load Rewarded video ads
AdTimingAds.init(this, appkey, mcallback, AdTimingAds.AD_TYPE.REWARDED_VIDEO); 
// Init with pre-load Interstitial ads
AdTimingAds.init(this, appkey, mcallback, AdTimingAds.AD_TYPE.INTERSTITIAL); 
// Init with no pre-load 
AdTimingAds.init(this, appkey, mcallback, AdTimingAds.AD_TYPE.NONE); 
// No need to invoke init for Banner and Native.


  • Important! The AD_UNITs of REWARDED_VIDEO and INTERSTITIAL must be initiated if you want to serve them in app, otherwise the SDK won't fetch and cache Ads inventory automaticly.
  • AD_Units such as Native and Banner Ad have no need to initiate separately. 

 Implement the Callback

The AdTiming SDK fires several events to inform you of your initialing SDK operation. To receive these events, register to the callback in the init() and implement the onSuccess() and onError() of it.

public void onSuccess() {
    // Add code here to process init success event.
public void onError(AdTimingError error) {
    // Add code here to process init failed event.
    // Parameter message tells the error information.


  • The error parameter in onError callback describes the cause of failure. Check the Error Code for more information and guidance on errors. 


Send attribution data to AdTiming(optional)

If your project also integrates the AppsFlyer SDK, we need you to pass the application attribution data to AdTiming so that we can help you accurately calculate each Media Source, Campaign level ROAS, and LTV data.

1. When you receive the onConversionDataSuccess callback you can use the sendAFConversionData method for passing the attribution data dictionary:

For apps using AppsFlyer SDK version 5 and above 

public void onConversionDataSuccess(Map<String, Object> conversionData) {
AdTimingAds.sendAFConversionData(conversionData); }

For apps using AppsFlyer SDK version 4 and below

public void onInstallConversionDataLoaded(Map<String, String> map) { {
AdTimingAds.sendAFConversionData(map); }

2. When you receive the onAppOpenAttribution callback you can use the sendAFDeepLinkData method for passing the attribution data dictionary:

public void onAppOpenAttribution(Map<String, String> conversionData) {
AdTimingAds.sendAFDeepLinkData(conversionData); }

What’s Next?

1. Integrate our Rewarded Video, Interstitial, Banner and Native Ads in your app.
2. Follow 
our Add Mediation Networks and Mediation Network Guides to mediation networks.

Note: With the AdTiming Mediation SDK, you need to download and add NOT ONLY the SDK of mediation networks you choose to work with BUT ALSO the adapters for those networks.

Was this article helpful?
7 out of 10 found this helpful



Article is closed for comments.