Android Question ADMOB

kalel

New Member
Hello everyone and sorry if I don't explain well ... I'm a neophyte. I have created an app and everything works fine. I have entered the codes for banners and insterstitials and the app crashes ... I am attaching what is included in the project .... I cannot understand what I wrong.

PROCESS GLOBALS
Dim m As MobileAds

GLOBALS
Private BannerAd As AdView
Private iAd As InterstitialAd

Activity_Create(FirstTime As Boolean)
Wait For (m.Initialize) MobileAds_Ready
m.SetConfiguration(m.CreateRequestConfigurationBuilder(Array("77A04EE40B2AFED2AFC67701365187EC"))) 'optional. Array with test device ids. See unfiltered logs to find id.

Dim AdaptiveSize As Map = GetAdaptiveAdSize
'Add Private BannerAd As AdView in Globals sub
BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111",AdaptiveSize.Get("native"))
Activity.AddView(BannerAd, 0, 0, AdaptiveSize.Get("width"), AdaptiveSize.Get("height"))
BannerAd.LoadAd

iAd.Initialize("iad", "ca-app-pub-3940256099942544/1033173712")
iAd.LoadAd

OTHER SUB
Sub GetAdaptiveAdSize As Map
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim AdSize As JavaObject
Dim width As Int = 100%x / GetDeviceLayoutValues.Scale
Dim Native As JavaObject = AdSize.InitializeStatic("com.google.android.gms.ads.AdSize").RunMethod("getCurrentOrientationAnchoredAdaptiveBannerAdSize", Array(ctxt, width))
Return CreateMap("native": Native, "width": Native.RunMethod("getWidthInPixels", Array(ctxt)), _
"height": Native.RunMethod("getHeightInPixels", Array(ctxt)))
End Sub

Sub Ad_ReceiveAd
Log("Adview received")
End Sub

Sub Ad_FailedToReceiveAd (ErrorCode As String)
Log("Failed: " & ErrorCode)
End Sub

Sub Ad_AdClosed
Log("Closed")
End Sub

Sub Ad_AdOpened
Log("Opened")
End Sub

Sub iAd_ReceiveAd
Log("IAd received. Now wait for the right moment to show the ad.")
If iAd.Ready Then
iAd.Show 'bad example. You should instead wait for the correct time and show it when it makes sense.
End If
End Sub

Sub iAd_FailedToReceiveAd (ErrorCode As String)
Log("Failed: " & ErrorCode)
End Sub

Sub iAd_AdClosed
Log("Closed")
End Sub

Sub iAd_AdOpened
Log("Opened")
End Sub


MANIFEST
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile (Macro, FirebaseAdMob.FirebaseAds)
AddReplacement($ADMOB_APP_ID$, ca-app-pub-12673333333~67613333333)
 
Top