0

Now I've tried to add AdMob(Banner) to my flutter project.

I add all dependencies to

  1. pubspec.yaml(google_mobile_ads: ^2.3.0)
  2. Info.plist
<key>GADApplicationIdentifier</key>
    <string>test id</string>
  1. AndroidManifest.xml
<meta-data
           android:name="com.google.android.gms.ads.APPLICATION_ID"
           android:value="test id"/>
  1. import right package file too.
import 'package:google_mobile_ads/google_mobile_ads.dart';

But as you can see, this error doesn't disappear at all.. I used exactly same code which described in the official document. Not only for the parameters, other method(like load()) cannot find too. https://developers.google.com/admob/flutter/banner/get-started?hl=ko

enter image description here

is anyone there who has same problem? If you have any idea about this error, please let me know how to fix it! I'm spending three days with this error, but did't get a solution yet.

I tried build the project several times. Also close and restart Android Studio, delete dependency and add Again. Also I checked sdk, flutter, Android Studio version too. But still don't know what's the problem and how to fix.

chloe
  • 1
  • their is import confliction in your app thats why its showing this error or it could be dependency download error try flutter clean than flutter pub get – Ali Hassan Feb 20 '23 at 05:20
  • @AliHassan Thank you for the suggestion. But it seems have no problem with dependencies. But I just found the other solution. Using 'AdManagerBannerAd' instead of 'BannerAd'. I still don't know why BannerAdd is not working. But AdManagerBannerAd works very well! – chloe Feb 20 '23 at 06:44
  • it think their is import in you file that have same BannerAdd name like google admob import banner add you can check its correct import by clicking on ctrl+mouseleftclick it take you to its original class – Ali Hassan Feb 20 '23 at 12:32
  • import 'package:google_mobile_ads/google_mobile_ads.dart' as googleAdMob; then try googleAdMob.BannerAdd i hope it will resolve your issue i am using same admob version but i am not getting any kind of error like your every thing working perfectly – Ali Hassan Feb 20 '23 at 12:34
  • @Ali Hassan Thank you! As you said, I changed 'default import' to 'named import' and the error is gone! It works perfectly well. Thank you! – chloe Feb 20 '23 at 15:00

0 Answers0