diff --git a/.ci/legacy_project/README.md b/.ci/legacy_project/README.md index 322e5b6ca00..ff859c3b369 100644 --- a/.ci/legacy_project/README.md +++ b/.ci/legacy_project/README.md @@ -55,3 +55,5 @@ and then deleting everything but `android/` from it: from version 1.9.0 to 2.1.0. If a user runs into an error with the AGP version, the warning is clear on how to upgrade the version to one that we support. - Modifies `gradle.properties` to not set android.enableJetifier=true. +- Update `app/build.gradle` to enable library desugaring to support + `interactive_media_ads` plugin. diff --git a/.ci/legacy_project/all_packages/android/app/build.gradle b/.ci/legacy_project/all_packages/android/app/build.gradle index 541aeed1a22..9ec72af3691 100644 --- a/.ci/legacy_project/all_packages/android/app/build.gradle +++ b/.ci/legacy_project/all_packages/android/app/build.gradle @@ -26,6 +26,10 @@ android { namespace = "com.example.all_packages" compileSdkVersion flutter.compileSdkVersion + compileOptions { + coreLibraryDesugaringEnabled true + } + defaultConfig { applicationId "com.example.all_packages" minSdkVersion flutter.minSdkVersion @@ -44,3 +48,7 @@ android { flutter { source '../..' } + +dependencies { + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5' +} diff --git a/packages/interactive_media_ads/CHANGELOG.md b/packages/interactive_media_ads/CHANGELOG.md index 648518c6522..b3acd96953a 100644 --- a/packages/interactive_media_ads/CHANGELOG.md +++ b/packages/interactive_media_ads/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.3.0 + +* Bumps `com.google.ads.interactivemedia.v3:interactivemedia` from 3.36.0 to 3.37.0. +* **Breaking Change** Adds app desugaring as a requirement for Android apps. Apps without desugaring + enabled won't build with the current or future IMA versions. To enable app desugaring, see + `README.md`. +* **Breaking Change** Updates `AdsRequest.adTagUrl` to return `null` when an ad tag is not set. + ## 0.2.8+1 * Resolves Gradle 9 deprecations. diff --git a/packages/interactive_media_ads/android/build.gradle b/packages/interactive_media_ads/android/build.gradle index 80304caa837..3c6bfeeebe4 100644 --- a/packages/interactive_media_ads/android/build.gradle +++ b/packages/interactive_media_ads/android/build.gradle @@ -50,7 +50,7 @@ android { dependencies { implementation("androidx.annotation:annotation:1.9.1") implementation("androidx.core:core-ktx:1.13.0") - implementation("com.google.ads.interactivemedia.v3:interactivemedia:3.36.0") + implementation("com.google.ads.interactivemedia.v3:interactivemedia:3.37.0") testImplementation("junit:junit:4.13.2") testImplementation("org.jetbrains.kotlin:kotlin-test") testImplementation("org.mockito.kotlin:mockito-kotlin:6.0.0") diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt index 6967af134a4..659043bd978 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt @@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : * * This must match the version in pubspec.yaml. */ - const val pluginVersion = "0.2.8+1" + const val pluginVersion = "0.3.0" } override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) { diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift index aa0ed1cf0c9..e2200fd037b 100644 --- a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift @@ -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.8+1" + static let pluginVersion = "0.3.0" func pigeonDefaultConstructor( pigeonApi: PigeonApiIMAAdsRequest, adTagUrl: String, adDisplayContainer: IMAAdDisplayContainer, diff --git a/packages/interactive_media_ads/lib/src/ads_request.dart b/packages/interactive_media_ads/lib/src/ads_request.dart index a68e1dff526..26bcb6c8141 100644 --- a/packages/interactive_media_ads/lib/src/ads_request.dart +++ b/packages/interactive_media_ads/lib/src/ads_request.dart @@ -68,12 +68,9 @@ class AdsRequest { final PlatformAdsRequest platform; /// The URL from which ads will be requested. - String get adTagUrl => switch (platform) { + String? get adTagUrl => switch (platform) { final PlatformAdsRequestWithAdTagUrl request => request.adTagUrl, - // TODO(bparrishMines): This returns an empty string rather than null - // to prevent a breaking change. This should be updated to return null - // on the next major release. - PlatformAdsRequestWithAdsResponse() => '', + PlatformAdsRequestWithAdsResponse() => null, }; /// Specifies a VAST, VMAP, or ad rules response to be used instead of making diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml index d63ac4db0ae..862e12e2a57 100644 --- a/packages/interactive_media_ads/pubspec.yaml +++ b/packages/interactive_media_ads/pubspec.yaml @@ -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.8+1 # This must match the version in +version: 0.3.0 # 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` diff --git a/script/tool/lib/src/create_all_packages_app_command.dart b/script/tool/lib/src/create_all_packages_app_command.dart index d50dc0d22df..2afdd82d1dc 100644 --- a/script/tool/lib/src/create_all_packages_app_command.dart +++ b/script/tool/lib/src/create_all_packages_app_command.dart @@ -239,6 +239,11 @@ dependencies {} ? ' implementation("androidx.lifecycle:lifecycle-runtime:2.2.0-rc01")' : " implementation 'androidx.lifecycle:lifecycle-runtime:2.2.0-rc01'"; + // Desugaring is required for interactive_media_ads. + final String desugaringDependency = gradleFileIsKotlin + ? ' coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")' + : " coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'"; + _adjustFile( gradleFile, replacements: >{ @@ -249,6 +254,14 @@ dependencies {} } }, regexReplacements: >{ + // Desugaring is required for interactive_media_ads. + RegExp(r'compileOptions\s+{$'): [ + 'compileOptions {', + if (gradleFileIsKotlin) + 'isCoreLibraryDesugaringEnabled = true' + else + 'coreLibraryDesugaringEnabled true', + ], // Tests for https://github.com/flutter/flutter/issues/43383 // Handling of 'dependencies' is more complex since it hasn't been very // stable across template versions. @@ -256,12 +269,14 @@ dependencies {} RegExp(r'^dependencies\s+{\s*}$'): [ 'dependencies {', lifecycleDependency, + desugaringDependency, '}', ], // - Handle a normal dependencies section. RegExp(r'^dependencies\s+{$'): [ 'dependencies {', lifecycleDependency, + desugaringDependency, ], // - See below for handling of the case where there is no dependencies // section.