Skip to content

fix(android): return ad size for AdLoaderAd banners on Next-Gen SDK - #5

Closed
felipefuzaro-funda wants to merge 6 commits into
msbit:ad-loader-adfrom
felipefuzaro-funda:fix/ad-loader-ad-size
Closed

felipefuzaro-funda wants to merge 6 commits into
msbit:ad-loader-adfrom
felipefuzaro-funda:fix/ad-loader-ad-size

Conversation

@felipefuzaro-funda

Copy link
Copy Markdown

Summary

Fixes AdLoaderAd.getAdSize() always returning null on the Next-Gen Ads SDK (adsNextGenSdk). Banner ads loaded via AdLoaderAd now report their size, matching the legacy (playServices) behavior.

Problem

In the Next-Gen source set, FlutterAdLoaderAd#getAdSize() was a stub returning null, so size was unavailable for AdLoaderAd banners while legacy worked.

Fix

Derive the size from the loaded banner AdView via getBannerAd().getAdSize(), the same call used by Next-Gen FlutterBannerAd. The instanceof AdView guard keeps custom/native types returning null. No new imports needed.

msbit and others added 5 commits August 21, 2026 18:14
Allow the `AdLoaderAd` instance to serve `Banner` ads, which are
instances of:

  * `AdManagerAdView`/`BannerAd` under Android, and
  * `GAMBannerView` under iOS
Allow the `AdLoaderAd` instance to serve `Custom` ads, which are
instances of:

  * `NativeCustomFormatAd`/`CustomNativeAd` under Android, and
  * `GADCustomNativeAd` under iOS
Allow the `AdLoaderAd` instance to serve `Native` ads, which are
instances of:

  * `NativeAd` under Android, and
  * `GADNativeAd` under iOS
@msbit

msbit commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Hey @felipefuzaro-funda! A couple of observations:

  • AdView.getBannerAd seems implicitly nullable: Gets the current BannerAd displayed in this AdView, if one exists.
  • whereas BannerAd.getAdSize is marked explicitly NonNull, and
  • there is a perhaps more suitable constructor for FlutterAdSize that takes an AdSize directly, saving an allocation (the (int,int) constructor delegates to the (AdSize) one).

Putting that together, the second half of the method might be better as:

final BannerAd bannerAd = ((AdView) view).getBannerAd();
if (bannerAd == null) {
  return null;
}
return new FlutterAdSize(bannerAd.getAdSize());

@felipefuzaro-funda

Copy link
Copy Markdown
Author

Hey @felipefuzaro-funda! A couple of observations:

  • AdView.getBannerAd seems implicitly nullable: Gets the current BannerAd displayed in this AdView, if one exists.
  • whereas BannerAd.getAdSize is marked explicitly NonNull, and
  • there is a perhaps more suitable constructor for FlutterAdSize that takes an AdSize directly, saving an allocation (the (int,int) constructor delegates to the (AdSize) one).

Putting that together, the second half of the method might be better as:

final BannerAd bannerAd = ((AdView) view).getBannerAd();
if (bannerAd == null) {
  return null;
}
return new FlutterAdSize(bannerAd.getAdSize());

good points @msbit, thanks!

@msbit

msbit commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Ok @felipefuzaro-funda, I've brought in your work, squashing it into the relevant commit and adding you as a co-auther. If you're happy with where ad-loader-ad is now, I can tag that (likely as v9.0.0-ad-loader-ad-2).

@felipefuzaro-funda

Copy link
Copy Markdown
Author

Ok @felipefuzaro-funda, I've brought in your work, squashing it into the relevant commit and adding you as a co-auther. If you're happy with where ad-loader-ad is now, I can tag that (likely as v9.0.0-ad-loader-ad-2).

yes, it looks good to me. A new tag would be great. Thank you @msbit

@msbit

msbit commented Sep 28, 2026

Copy link
Copy Markdown
Owner

@felipefuzaro-funda pushed up as v9.0.0-ad-loader-ad-3 (off by one 🤣).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants