Futter: Cannot find 'kGADAdSizeBanner' in scope
Asked Answered
B

2

6

Error on iOS:

Cannot find 'kGADAdSizeBanner' in scope

Line:

private var adSize: GADAdSize = kGADAdSizeBanner

Package:

native_admob_flutter

Extra info:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.0, on macOS 11.6.2 20G314 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.62.0)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

Android works. Official Flutter package for ads (google_mobile_ads) is totally dead so changing to that one is not an option anymore.

Beaulieu answered 5/2, 2022 at 10:7 Comment(3)
Some part of this answer would be helpful for you > github.com/flutter/flutter/issues/8098Phytography
but it says "This issue is now specifically about Native Ads from Facebook and AdMob."Beaulieu
I just came across the exact issue, I forked the repo and did some minor migration so it can fit the latest Mobile Ads SDK (iOS). Hope it helps: github.com/nathan1658/native_admob_flutterTrussing
G
2

Not sure if this will help but I faced this same issue. So I looked at the Banner-Ad size section from their documentation, and just made a custom GADAdsize var.

For example if you wanted a Large Banner(kGADAdSizeLargeBanner), then the documentation shows that the size in points (Width x Height) is 320x100.

Size for whatever reason we can't access the variable kGADAdSizeLargeBanner (or kGADAdSizeBanner in your case) we can just create our own.

let adSize = GADAdSizeFromCGSize(CGSize(width: 320, height: 100))

Then using this adSize variable we can initialize a banner view.

let bannerView: GADBannerView = GADBannerView(adSize: adSize)

More detailed info about GADAdSizeFromCGSize can be found at this link.

Gonfanon answered 8/2, 2022 at 14:54 Comment(1)
for my case I use that package that should covers already that implementation. I don't create the banner, like that, only call the method to import themBeaulieu
M
19

See docs , you just need to remove the 'k' at the beginning because they update it for the iOS SDK. From: kGADAdSizeBanner to GADAdSizeBanner.

Mattern answered 26/3, 2022 at 17:32 Comment(1)
OP, this is the best answer. You should designate it as such.Innumerable
G
2

Not sure if this will help but I faced this same issue. So I looked at the Banner-Ad size section from their documentation, and just made a custom GADAdsize var.

For example if you wanted a Large Banner(kGADAdSizeLargeBanner), then the documentation shows that the size in points (Width x Height) is 320x100.

Size for whatever reason we can't access the variable kGADAdSizeLargeBanner (or kGADAdSizeBanner in your case) we can just create our own.

let adSize = GADAdSizeFromCGSize(CGSize(width: 320, height: 100))

Then using this adSize variable we can initialize a banner view.

let bannerView: GADBannerView = GADBannerView(adSize: adSize)

More detailed info about GADAdSizeFromCGSize can be found at this link.

Gonfanon answered 8/2, 2022 at 14:54 Comment(1)
for my case I use that package that should covers already that implementation. I don't create the banner, like that, only call the method to import themBeaulieu

© 2022 - 2025 — McMap. All rights reserved.