Android Question Admob ad problem

wasro

Member
This is how I placed the Admob ad codes.

When I add these, my project does not open. It doesn't give any error.

Am I using it in the wrong place? Can you help me?



MANİFEST EDİTÖRÜ

AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="30"/>
<destek-ekranlar android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)

SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Makro, Themes.DarkTheme)
CreateResourceFromFile(Makro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile (Makro, FirebaseAdMob.FirebaseAds)
AddReplacement($ADMOB_APP_ID$, ca-app-pub-9668793563301972/1186560484)

MAIN

Sub Globals

Private BannerAd As AdView


Private gm As Game
End Sub


Sub Activity_Create(FirstTime As Boolean)

Dim AdaptiveSize As Map = GetAdaptiveAdSize

BannerAd.Initialize2("BannerAd", "ca-app-pub-9668793563301972/1186560484",AdaptiveSize.Get("native"))
Activity.AddView(BannerAd, 0, 0, AdaptiveSize.Get("width"), AdaptiveSize.Get("height"))
BannerAd.LoadAd
gm.Initialize(Activity)
End Sub


Sub Activity_Resume

gm.Utils.Start
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

STARTER
Sub Service_Create
Dim m As MobileAds
Wait For (m.Initialize) MobileAds_Ready
m.SetConfiguration(m.CreateRequestConfigurationBuilder(Array("77A04EE40B2AFED2AFC67701365187EC")))
End Sub
 
Last edited:

asales

Well-Known Member
Licensed User
Longtime User
1 - Please post the code with CODE tags.
2 - Check this example:
 
Upvote 0
Top