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 already 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.
repositories {
jcenter()
mavenCentral()
... << other repositories omitted >> ...
maven {
url "https://maven.google.com/"
}
}
GROOVY
Add the following third-party dependencies.
... <<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'
}
GROOVY
To resolve conflicts in child dependencies, you will need a gradle.properties
file.
android.useAndroidX=true
android.enableJetifier=true
GROOVY
Next step: Enable playback of linear adverts.