From fa15ddcd69cebaa10665d676bebeae2c32c7ec20 Mon Sep 17 00:00:00 2001 From: jjliu15 <58007281+jjliu15@users.noreply.github.com> Date: Tue, 15 Nov 2022 09:56:37 -0800 Subject: [PATCH] Fix warnings and update versions (#694) * Fix java warnings and update GMA Android to 21.3.0 and iOS to 9.13 --- packages/google_mobile_ads/CHANGELOG.md | 5 +++++ packages/google_mobile_ads/android/build.gradle | 3 ++- .../io/flutter/plugins/googlemobileads/Constants.java | 2 +- .../googlemobileads/FlutterAdManagerAdRequest.java | 5 +++++ .../plugins/googlemobileads/FlutterAdRequest.java | 10 ++++++++++ .../googlemobileads/FlutterRequestAgentProvider.java | 2 -- packages/google_mobile_ads/ios/Classes/FLTConstants.h | 2 +- .../google_mobile_ads/ios/google_mobile_ads.podspec | 2 +- packages/google_mobile_ads/pubspec.yaml | 2 +- 9 files changed, 26 insertions(+), 7 deletions(-) diff --git a/packages/google_mobile_ads/CHANGELOG.md b/packages/google_mobile_ads/CHANGELOG.md index 2afbf213a..8b153807d 100644 --- a/packages/google_mobile_ads/CHANGELOG.md +++ b/packages/google_mobile_ads/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.3.0 +* Updates GMA iOS dependency to 9.13 +* Updates GMA Android dependency to 21.3.0 +* Updates request agent string based on metadata in AndroidManifest.xml or Info.plist + ## 2.2.0 * Updates GMA iOS dependency to 9.11.0. This fixes dependency issues in apps that also depend on the latest version of Firebase: https://github.com/googleads/googleads-mobile-flutter/issues/673 diff --git a/packages/google_mobile_ads/android/build.gradle b/packages/google_mobile_ads/android/build.gradle index ecc69d10a..f531d3e1d 100644 --- a/packages/google_mobile_ads/android/build.gradle +++ b/packages/google_mobile_ads/android/build.gradle @@ -31,8 +31,9 @@ android { disable 'InvalidPackage' } dependencies { - api 'com.google.android.gms:play-services-ads:21.2.0' + api 'com.google.android.gms:play-services-ads:21.3.0' implementation 'androidx.lifecycle:lifecycle-process:2.2.0' + implementation 'com.google.errorprone:error_prone_annotations:2.16' testImplementation 'junit:junit:4.12' testImplementation 'org.hamcrest:hamcrest:2.2' testImplementation 'org.mockito:mockito-inline:3.9.0' diff --git a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/Constants.java b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/Constants.java index 22b1b6913..32fc4be13 100644 --- a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/Constants.java +++ b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/Constants.java @@ -17,7 +17,7 @@ /** Constants used in the plugin. */ public class Constants { /** Version request agent. Should be bumped alongside plugin versions. */ - public static final String REQUEST_AGENT_PREFIX_VERSIONED = "Flutter-GMA-2.2.0"; + public static final String REQUEST_AGENT_PREFIX_VERSIONED = "Flutter-GMA-2.3.0"; /** Prefix for news template */ public static final String REQUEST_AGENT_NEWS_TEMPLATE_PREFIX = "News"; diff --git a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterAdManagerAdRequest.java b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterAdManagerAdRequest.java index 45b3f0326..b0eca5972 100644 --- a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterAdManagerAdRequest.java +++ b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterAdManagerAdRequest.java @@ -17,6 +17,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.android.gms.ads.admanager.AdManagerAdRequest; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.List; import java.util.Map; import java.util.Objects; @@ -37,22 +38,26 @@ static class Builder extends FlutterAdRequest.Builder { @Nullable private Map> customTargetingLists; @Nullable private String publisherProvidedId; + @CanIgnoreReturnValue public Builder setCustomTargeting(@Nullable Map customTargeting) { this.customTargeting = customTargeting; return this; } + @CanIgnoreReturnValue public Builder setCustomTargetingLists( @Nullable Map> customTargetingLists) { this.customTargetingLists = customTargetingLists; return this; } + @CanIgnoreReturnValue public Builder setPublisherProvidedId(@Nullable String publisherProvidedId) { this.publisherProvidedId = publisherProvidedId; return this; } + @Override FlutterAdManagerAdRequest build() { return new FlutterAdManagerAdRequest( getKeywords(), diff --git a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterAdRequest.java b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterAdRequest.java index fd8b1b63f..78b5c6a22 100644 --- a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterAdRequest.java +++ b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterAdRequest.java @@ -20,6 +20,7 @@ import com.google.ads.mediation.admob.AdMobAdapter; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.mediation.MediationExtrasReceiver; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,47 +49,56 @@ protected static class Builder { @Nullable private Map adMobExtras; @NonNull private String requestAgent; + @CanIgnoreReturnValue Builder setRequestAgent(String requestAgent) { this.requestAgent = requestAgent; return this; } + @CanIgnoreReturnValue Builder setKeywords(@Nullable List keywords) { this.keywords = keywords; return this; } + @CanIgnoreReturnValue Builder setContentUrl(@Nullable String contentUrl) { this.contentUrl = contentUrl; return this; } + @CanIgnoreReturnValue Builder setNonPersonalizedAds(@Nullable Boolean nonPersonalizedAds) { this.nonPersonalizedAds = nonPersonalizedAds; return this; } + @CanIgnoreReturnValue Builder setNeighboringContentUrls(@Nullable List neighboringContentUrls) { this.neighboringContentUrls = neighboringContentUrls; return this; } + @CanIgnoreReturnValue Builder setHttpTimeoutMillis(@Nullable Integer httpTimeoutMillis) { this.httpTimeoutMillis = httpTimeoutMillis; return this; } + @CanIgnoreReturnValue Builder setMediationNetworkExtrasIdentifier(@Nullable String mediationExtrasIdentifier) { this.mediationExtrasIdentifier = mediationExtrasIdentifier; return this; } + @CanIgnoreReturnValue Builder setMediationNetworkExtrasProvider( @Nullable MediationNetworkExtrasProvider mediationNetworkExtrasProvider) { this.mediationNetworkExtrasProvider = mediationNetworkExtrasProvider; return this; } + @CanIgnoreReturnValue Builder setAdMobExtras(@Nullable Map adMobExtras) { this.adMobExtras = adMobExtras; return this; diff --git a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterRequestAgentProvider.java b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterRequestAgentProvider.java index 65e4da52c..2366c40bf 100644 --- a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterRequestAgentProvider.java +++ b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterRequestAgentProvider.java @@ -15,12 +15,10 @@ class FlutterRequestAgentProvider { static final String NEWS_VERSION_KEY = "io.flutter.plugins.googlemobileads.FLUTTER_NEWS_TEMPLATE_VERSION"; - private final Context context; @Nullable private String newsTemplateVersion; @Nullable private String gameTemplateVersion; FlutterRequestAgentProvider(Context context) { - this.context = context; processGameAndNewsTemplateVersions(context); } diff --git a/packages/google_mobile_ads/ios/Classes/FLTConstants.h b/packages/google_mobile_ads/ios/Classes/FLTConstants.h index 05c3cd040..2689a596a 100644 --- a/packages/google_mobile_ads/ios/Classes/FLTConstants.h +++ b/packages/google_mobile_ads/ios/Classes/FLTConstants.h @@ -13,4 +13,4 @@ // limitations under the License. /** Versioned request agent string. */ -#define FLT_REQUEST_AGENT_VERSIONED @"Flutter-GMA-2.2.0" +#define FLT_REQUEST_AGENT_VERSIONED @"Flutter-GMA-2.3.0" diff --git a/packages/google_mobile_ads/ios/google_mobile_ads.podspec b/packages/google_mobile_ads/ios/google_mobile_ads.podspec index 8d42968c3..1892ee4d3 100644 --- a/packages/google_mobile_ads/ios/google_mobile_ads.podspec +++ b/packages/google_mobile_ads/ios/google_mobile_ads.podspec @@ -15,7 +15,7 @@ Google Mobile Ads plugin for Flutter. s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - s.dependency 'Google-Mobile-Ads-SDK','~> 9.11' + s.dependency 'Google-Mobile-Ads-SDK','~> 9.13' s.ios.deployment_target = '10.0' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => 'armv7 arm64 x86_64' } s.static_framework = true diff --git a/packages/google_mobile_ads/pubspec.yaml b/packages/google_mobile_ads/pubspec.yaml index 383d829ee..cde228733 100644 --- a/packages/google_mobile_ads/pubspec.yaml +++ b/packages/google_mobile_ads/pubspec.yaml @@ -13,7 +13,7 @@ # limitations under the License. name: google_mobile_ads -version: 2.2.0 +version: 2.3.0 description: Flutter plugin for Google Mobile Ads, supporting banner, interstitial (full-screen), rewarded and native ads repository: https://github.com/googleads/googleads-mobile-flutter/tree/main/packages/google_mobile_ads