Add an ad client dependency (Android)
Enable Google IMA and Google DAI ad requests in your Android app
If you are not using Google IMA or Google DAI to serve your ads, skip to Schedule VAST ads.
The JWX Android SDK integrates the Google IMA and Google DAI SDKs that you can request ads.
Google IMA ads allow you to integrate multimedia ads into your websites and apps1. Google Dynamic Ad Insertion (DAI) allows you to serve video ads into live linear programming and video on demand content2.
1. Source: Interactive Media Ads SDKs
2. Source: Learn about Dynamic Ad Insertion (DAI)
Prerequisites
Google IMA
| Item | Description |
|---|---|
| Embedded JWX player | JWX player with content |
| Ad tag | (IMA, VAST) URL of the ad tag for VAST and IMA plugins.
|
Google DAI
| Item | Description |
|---|---|
| Embedded JWX player | JWX player with content |
| Ad tag | (IMA, VAST) URL of the ad tag for VAST and IMA plugins.
|
| Google Ad Manager 360 | Server-side DAI backend used by the IMA SDK for ad decisioning, stream stitching, and tracking for live and on-demand content |
Add Google IMA client dependencies
Gradle
Follow these steps to add the dependencies:
-
In the build.gradle file of your app, add com.jwplayer:jwplayer-ima:$jwPlayerVersion. Be sure to define the dependency version number (
$jwPlayerVersion).dependencies { ... implementation 'com.jwplayer:jwplayer-core:$jwPlayerVersion' implementation 'com.jwplayer:jwplayer-common:$jwPlayerVersion' implementation 'com.jwplayer:jwplayer-ima:$jwPlayerVersion' implementation 'com.google.ads.interactivemedia.v3:interactivemedia:$googleImaVersion' implementation 'com.google.android.gms:play-services-ads-identifier:$googleImaVersion' } -
Enable desugaring.
Core library desugaring enables newer Java standard library APIs to be used on older Android versions by rewriting them at build time.
dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5' // Use the latest version recommended by the Android Gradle Plugin. } android { defaultConfig { multiDexEnabled true // Optional. This may be required depending on app method count. } compileOptions { coreLibraryDesugaringEnabled true } } -
When prompted, click Sync Now to apply the Gradle changes.
Local
Follow these steps to add the dependencies:
- With your app open in Android Studio, click File > New > New Module... > Import .JAR / .AAR Package.
- Click Next.
- Select the jwplayer-ima-x.x.aar file from your computer.
If you do not have a jwplayer-ima-x.x.x.aar file on your computer, you can download the Android SDK .zip from your JWX dashboard.
- Click Finish.
- Click File > Project Structure... > Dependencies. Under Modules, be sure that your app is selected.
- Click the plus sign in the main panel.
- Select Module dependency.
- Select the checkbox next to the name of each dependency that needs to be added.
- Click OK.
- Click Apply.
- Click OK.
Enable desugaring
Follow these steps to enable desugaring:
-
In the app build.gradle file of your app, enable desugaring.
Core library desugaring enables newer Java standard library APIs to be used on older Android versions by rewriting them at build time.
dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5' // Use the latest version recommended by the Android Gradle Plugin. } android { defaultConfig { multiDexEnabled true // Optional. This may be required depending on app method count. } compileOptions { coreLibraryDesugaringEnabled true } } -
When prompted, click Sync Now to apply the Gradle changes.
Add Google DAI client dependencies
Gradle
Follow these steps to add the dependencies:
-
In the app build.gradle file of your app, add com.jwplayer:jwplayer-ima:$jwPlayerVersion. Be sure to define the dependency version number (
$jwPlayerVersion).dependencies { ... implementation 'com.jwplayer:jwplayer-core:$jwPlayerVersion' implementation 'com.jwplayer:jwplayer-common:$jwPlayerVersion' implementation 'com.jwplayer:jwplayer-ima:$jwPlayerVersion' implementation 'com.google.ads.interactivemedia.v3:interactivemedia:$googleImaVersion' implementation 'com.google.android.gms:play-services-ads-identifier:$googleImaVersion' } -
When prompted, click Sync Now to apply the Gradle changes.
Local
Follow these steps to add the dependencies:
- With your app open in Android Studio, click File > New > New Module... > Import .JAR / .AAR Package.
- Click Next.
- Select the jwplayer-ima-x.x.aar file from your computer.
If you do not have a jwplayer-ima-x.x.x.aar file on your computer, you can download the Android SDK .zip from your JWX dashboard.
- Click Finish.
- Click File > Project Structure... > Dependencies. Under Modules, be sure that your app is selected.
- Click the plus sign in the main panel.
- Select Module dependency.
- Select the checkbox next to the name of each dependency that needs to be added.
- Click OK.
- Click Apply.
- Click OK.
Updated 13 days ago
