Android Question Adding AdMob Ad in B4A v. 10.2

Juzer Hussain

Active Member
Licensed User
Longtime User
I am trying to add adv. through Admob in my project in B4A 10.2. I have referenced Firebase Admob library, added google-services.jason file in folder and added below lines in manifest.

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)

Just to check i added below code in Activity_Create

B4X:
   'Admob
    BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111", BannerAd.SIZE_SMART_BANNER)
    Dim height As Int
    If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
        'phones
        If 100%x > 100%y Then height = 32dip Else height = 50dip
    Else
        'tablets
        height = 90dip
   End If

    Activity.AddView(BannerAd, 0dip, 100%y - height, 100%x, height)
    BannerAd.LoadAd
    IAd.Initialize("iad", "ca-app-pub-3940256099942544/1033173712")
    IAd.LoadAd

I have added my project in Firebase.

When i run the project it crashes in mobile.

I think i am missing something.

Can someone pls give some clue.

Thanks
Juzer
 

Pendrush

Well-Known Member
Licensed User
Longtime User
You should check crash log, also you maybe missing this line in manifest.
B4X:
AddReplacement($ADMOB_APP_ID$, ca-app-pub-3940256099942544~3347511713) 'This is test ID. Replace it with yours app ID
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…