Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is BannerAd.testAdUnitID is out dated?

I am following a tutorial of adding a Banner Ad. But for me it gives this error.

The getter 'testAdUnitID' isn't defined for the type 'BannerAd'. 

Is testAdUnitID is deprecated or something? What's the way out?

My code is:

  void _initBannerAd() {
    _bannerAd = BannerAd(
      size: AdSize.banner,
      adUnitId: BannerAd.testAdUnitID,
      listener: BannerAdListener(),
      request: AdRequest(),
    );
  }

Here is the screenshot:

Screenshot

like image 997
Saad Mansoor Avatar asked Dec 06 '25 04:12

Saad Mansoor


1 Answers

Which tutorial did you watch?

edit

found update log here.

https://pub.dev/packages/google_mobile_ads/changelog

  • 2.0.0
    • Removes static testAdUnitId parameters. See the Admob and AdManager documentation for up to date test ad units.

solution

you can get some test id for adUnitId from here.

https://developers.google.com/admob/android/test-ads

and flutter sample here.

https://developers.google.com/admob/flutter/test-ads

like image 75
rodpold Avatar answered Dec 11 '25 04:12

rodpold



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!