Hi all
I'm following this tutorial about FirebaseAdMob2 - Google Mobile Ads. But when I ran the application I get this error:
this is my code:
thanks.
I'm following this tutorial about FirebaseAdMob2 - Google Mobile Ads. But when I ran the application I get this error:
B4X:
B4A Version: 10.90
Parsing code. (0.00s)
Java Version: 11
Building folders structure. (0.01s)
Compiling code. (0.01s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Compiling resources (0.09s)
Linking resources (0.39s)
Compiling generated Java code. Error
B4A line: 30
Wait For (m.Initialize) MobileAds_Ready
src\b4a\example\main.java:378: error: method Initialize in class MobileAdsWrapper cannot be applied to given types;
anywheresoftware.b4a.keywords.Common.WaitFor("mobileads_ready", processBA, this, _m.Initialize(processBA));
^
required: no arguments
found: BA
reason: actual and formal argument lists differ in length
this is my code:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Private BannerAd As AdView
Private iAd As InterstitialAd
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
Dim m As MobileAds
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
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End 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
thanks.