Setup advertising with Google IMA
Since IMA is a third-party SDK and not shipped as part of the Bitmovin Player, you must first add the necessary dependencies to the project's build.gradle.kts or build.gradle file.
Additionally it is important, to use the +jason build flavor of the Bitmovin Player, as both the Bitmovin Player and the IMA SDK rely on different variants of the media3-common module.
In order to use the IMA SDK, starting with version 3.37.0, you need to enable coreLibraryDesugaring. (See also the Set up the IMA SDK Guide from Google)
android {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
implementation("com.google.ads.interactivemedia.v3:interactivemedia:3.37.0")
implementation("com.bitmovin.player:player:{version-number}+jason")
}
android {
compileOptions {
setCoreLibraryDesugaringEnabled(true)
}
}
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.37.0'
implementation 'com.bitmovin.player:player:{version-number}+jason'
}
Further add your Ad Manager app ID (identified in the Ad Manager UI) to your app's AndroidManifest.xml file. To do so, add a <meta-data> tag with android:name="com.google.android.gms.ads.APPLICATION_ID".
See also the Quick Start Guide from Google.
<manifest>
<application>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
<meta-data
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true" />
</application>
</manifest>
Initialize the IMA SDK
As a best practice, initialize the IMA SDK using the same ad rendering settings configured for your AdsLoader instance. Some internal IMA resources require additional time to load; to optimize startup performance, use the sdkFactory.initialize() method to preload these resources asynchronously on a background thread.
The Bitmovin Player automatically creates and manages the AdsLoader instance; however, you must explicitly trigger SDK initialization by invoking sdkFactory.initialize() in your application’s onCreate() method or main activity’s onCreate() method. See the official IMA documentation for further details.
Where to go from here?
By adding the dependencies the IMA integration is enabled in the Bitmovin Android Player and can be used with the AdSourceType.Ima. You can follow Setting up Ads with the Android SDK to schedule and play back your first ad.
Updated 17 days ago