Skip to main content
Skip table of contents

Adverts with Google IMA

To test this feature and view the example code, please see the Android SDK 5 Example Code Quick Start guide.

This application inserts advertisements using the IMAWrapper class via the Google Interactive Media Ads (IMA) SDK to access ad servers that support VAST and VMAP. For more information, see the Google IMA SDK for Android Get started and IMA sample tags pages.

Prerequisites

Advert server configured and knowledge of the ad tag URLs that will be used to access it.

Example code

The Java source code contains the IMAWrapper package that simplifies configuration and access to an ad server, as well as playback and display of the adverts. The following instructions show you how to modify your existing application to make use of the IMAWrapper package with the Google IMA libraries; the main stages are:

Project setup

In the application project you are building, update your Gradle script to fetch the Google IMA Play Services libraries from the Google Maven repository.

Add the repository.

GROOVY
    repositories {
      jcenter()
      mavenCentral()

    ... << other repositories omitted >> ...

      maven {
        url "https://maven.google.com/"
      }
    }

Add the following third-party dependencies.

GROOVY
 ... <<details omitted >> ...

    dependencies {
      ... << other dependencies omitted >> ...

      implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.26.0'
      implementation 'com.google.android.gms:play-services-ads:18.0.1'
    }

To resolve conflicts in child dependencies, you will need a gradle.properties file.

GROOVY
    android.useAndroidX=true
    android.enableJetifier=true

Next step: Enable playback of linear adverts.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.