Getting Started

Document created by david.simerly on Oct 24, 2017Last modified by david.simerly on May 8, 2018
Version 33Show Document
  • View in full screen mode

PubMatic SDKs 

PubMatic Android SDK

➤ Getting Started

Integrating Banner Ads

Integrating Interstitial Ads

Rich Media (MRAID 2.0) Support

Integrating Native Ads

Header Bidding With DFP

Passing Targeting Information

SDK Debugging

PubMatic Android SDK Reference 

This Getting Started guide walks you through everything you need to get started with the PubMatic Android SDK, beginning with the prerequisites for a successful integration.



PubMatic Android SDK requires the following:


  • Minimum Android SDK version 4.4 (API level 19) or greater.
  • Android Studio version 2.3.0 or greater.
  • PubMatic ad tag information (Publisher ID, Site ID, Ad ID). You'll find these values through the PubMatic platform. Contact your PubMatic Account Manager for more information.


Integrate PubMatic SDK

Integrate PubMatic Android SDK in your app using one of the following methods:



JitPack Central Repository

Step 1

You'll get the PubMatic Android SDK as an AAR from the JitPack Central Repository. Add PubMatic Android SDK dependencies to your project's build.gradle file:


allprojects {
    repositories {
        maven {
            url ""


Step 2

Add the following lines in the build.gradle of the application module. PubMatic SDK is modularized and provides the ad format and feature-specific libraries. Include one or more of the lines below in your application module build.gradle to include only the ad formats you need in your app. Including only the ad formats your app will actually use also reduces your app's file size.


// Integrate only Banner and Interstitial( With MRAID support )
compile 'com.github.PubMatic.pubmatic-sdk-android:banner-sdk:5.3.4'
// Integrate only Native
compile 'com.github.PubMatic.pubmatic-sdk-android:native-sdk:5.3.4'
// Integrate Header Bidding feature
compile 'com.github.PubMatic.pubmatic-sdk-android:header-bidding:5.3.4'


You can also add options to the app's build.gradle that always use the latest versions of libraries instead of static versions. Again, include only the formats your app will actually use:


// Integrate Banner and Interstitial( With MRAID support )
compile 'com.github.PubMatic.pubmatic-sdk-android:banner-sdk:-SNAPSHOT'
// Integrate only Native
compile 'com.github.PubMatic.pubmatic-sdk-android:native-sdk:-SNAPSHOT'
// Integrate Header Bidding feature
compile 'com.github.PubMatic.pubmatic-sdk-android:header-bidding:-SNAPSHOT'


This completes your integration from JitPack Central Repository. Skip the next section and continue with Adding Permissions to the AndroidManifest.xml File ⤵


Direct Source Code

To integrate the PubMatic Android SDK as source code within your app, download the PubMatic SDK code from the GitHub archives, then use the following steps.


Step 1

If you didn't do so in the Introduction, then download the PubMatic Android SDK and sample apps now. Copy or import the required modules from the PubMatic-Android-SDK project into your Android Studio project.


For example: Integrate banner ads into your app project by copying the common-sdk and the banner-sdk modules from PubMatic-Android-SDK into your Android Studio project folder.


Step 2

Add module dependency in your project's settings.gradle as shown below:


Remember that if you are using only specific ad formats or features, then specify only entries your app will use.


But you must include :pubmatic-sdk:common-sdk in the settings.gradle file.


include ':pubmatic-sdk:common-sdk', ':pubmatic-sdk:banner-sdk', 
':pubmatic-sdk:native-sdk', ':pubmatic-sdk:header-bidding'


Step 3

Add maven dependency in your project's build.gradle file as shown below:


dependencies {
        classpath ''
        // Add following line
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'


Step 4

Modify your app module's build.gradle file by adding the required common dependency of :pubmatic-sdk:common-sdk, then add your chosen ad format dependencies as shown below:


    // Integrate the common dependency. REQUIRED for ad format integration.
    compile project(':pubmatic-sdk:common-sdk')
    // Integrate Banner and Interstitial (with MRAID support)
    compile project(':pubmatic-sdk:banner-sdk')
    // Integrate Native
    compile project(':pubmatic-sdk:native-sdk')
    // Integrate Header Bidding feature
    compile project(':pubmatic-sdk:header-bidding')


This completes your Direct Source Code integration. Continue to the next section Adding Permissions to the AndroidManifest.xml File ⤵


Adding Permissions to the AndroidManifest.xml File

PubMatic SDK requires only two basic permissions declared in AndroidManifest.xml file, all others are optional.


Mandatory Permissions

PubMatic SDK must have the following set of permissions in the AndroidManifest.xml file.


PermissionDescription            Manifest file entry
InternetAccess the Internet. Required for ad-content download.<uses-permission android:name="android.permission.INTERNET" />
Network StateAccess the network state. Required for ad request parameter setting.<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


Optional Permissions

The following permissions are optional, based on your requirements.


PermissionDescription            Manifest file entry
Fine LocationUse GPS to obtain location information. Required if auto location detection in SDK is enabled.<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
External StorageAccess the SD card storage area. Required for photo, and file access to support MRAID features.<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />