Skip to content

[interactive_media_ads] Updates README with information about enabling desugaring on Android #9790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/interactive_media_ads/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.6+3

* Updates `README` with information about enabling desugaring on Android.

## 0.2.6+2

* Updates kotlin version to 2.2.0 to enable gradle 8.11 support.
Expand Down
37 changes: 33 additions & 4 deletions packages/interactive_media_ads/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ a separate video player positioned on top of the app's content video player.
| **Support** | SDK 21+ | 12.0+ |

**NOTE:**
* Companion ads, Background Audio ads and Google Dynamic Ad Insertion methods are currently not
supported.
* Background Audio ads and Google Dynamic Ad Insertion methods are currently not supported.

## IMA client-side overview

Expand All @@ -37,9 +36,13 @@ initialization and playback.
This guide demonstrates how to integrate the IMA SDK into a new `Widget` using the [video_player][7]
plugin to display content.

### 1. Add Android Required Permissions
### 1. Update Android App

If building on Android, add the user permissions required by the IMA SDK for requesting ads in
If not building for Android, skip this step.

#### Update Android Manifest

Add the user permissions required by the IMA SDK for requesting ads in
`android/app/src/main/AndroidManifest.xml`.

<?code-excerpt "example/android/app/src/main/AndroidManifest.xml (android_manifest)"?>
Expand All @@ -50,6 +53,32 @@ If building on Android, add the user permissions required by the IMA SDK for req
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
```

#### Update Android App-level Gradle

The IMA SDK requires library desugaring enabled, which you must do by setting
`coreLibraryDesugaringEnabled true` and adding
`coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'` as a dependency in the
`android/app/build.gradle` file. For more details, see
[Java 11+ APIs available through desugaring with the nio specification](https://developer.android.com/studio/write/java11-nio-support-table).
Comment on lines +60 to +62

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The link to the Android developer documentation is broken, and the specified dependency version for desugar_jdk_libs appears to be incorrect.

  1. The link on line 62 is broken. A correct link for Java 8+ desugaring is https://developer.android.com/studio/write/java8-support#library-desugaring.
  2. The version 2.1.5 for com.android.tools:desugar_jdk_libs on line 60 is not available in public Google Maven repositories. The latest stable version is 2.0.4. Please verify the correct dependency artifact and version.

I've suggested updating both the dependency and the link.

Suggested change
`coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'` as a dependency in the
`android/app/build.gradle` file. For more details, see
[Java 11+ APIs available through desugaring with the nio specification](https://developer.android.com/studio/write/java11-nio-support-table).
`coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'` as a dependency in the
`android/app/build.gradle` file. For more details, see
[Java 8+ language features](https://developer.android.com/studio/write/java8-support#library-desugaring).


<?code-excerpt "example/android/app/build.gradle (android_desugaring)"?>
```groovy
android {
// ···
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
// ···
}
// ···
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
// ···
}
```

### 2. Add Imports

Add the import statements for the `interactive_media_ads` and [video_player][7]. Both plugins should
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
*
* This must match the version in pubspec.yaml.
*/
const val pluginVersion = "0.2.6+2"
const val pluginVersion = "0.2.6+3"
}

override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) {
Expand Down
12 changes: 12 additions & 0 deletions packages/interactive_media_ads/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

// #docregion android_desugaring
android {
// #enddocregion android_desugaring
namespace "dev.flutter.packages.interactive_media_ads_example"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

// #docregion android_desugaring
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
// #enddocregion android_desugaring

kotlinOptions {
jvmTarget = '11'
Expand All @@ -54,15 +59,22 @@ android {
signingConfig signingConfigs.debug
}
}
// #docregion android_desugaring
}
// #enddocregion android_desugaring

flutter {
source '../..'
}

// #docregion android_desugaring
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This dependency version 2.1.5 appears to be incorrect as it's not available in public repositories. Please verify the correct version. The latest known public version is 2.0.4.

    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'

// #enddocregion android_desugaring
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
api 'androidx.test:core:1.4.0'
// #docregion android_desugaring
}
// #enddocregion android_desugaring
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AdsRequestProxyAPIDelegate: PigeonApiDelegateIMAAdsRequest {
/// The current version of the `interactive_media_ads` plugin.
///
/// This must match the version in pubspec.yaml.
static let pluginVersion = "0.2.6+2"
static let pluginVersion = "0.2.6+3"

func pigeonDefaultConstructor(
pigeonApi: PigeonApiIMAAdsRequest, adTagUrl: String, adDisplayContainer: IMAAdDisplayContainer,
Expand Down
2 changes: 1 addition & 1 deletion packages/interactive_media_ads/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: interactive_media_ads
description: A Flutter plugin for using the Interactive Media Ads SDKs on Android and iOS.
repository: https://github.com/flutter/packages/tree/main/packages/interactive_media_ads
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+interactive_media_ads%22
version: 0.2.6+2 # This must match the version in
version: 0.2.6+3 # This must match the version in
# `android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt` and
# `ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift`

Expand Down