Lucas Eduardo Active Member Licensed User Nov 20, 2019 #1 From code posted by Erel on this thread https://www.b4x.com/android/forum/threads/admob-adaptive-banners.111525/ 1: Code: Code: Copy Sub GetAdaptiveAdSize As AdSize Dim ctxt As JavaObject ctxt.InitializeContext Dim AdSize As JavaObject Dim width As Int = 100%x / GetDeviceLayoutValues.Scale Dim res As AdSize res.Native = AdSize.InitializeStatic("com.google.android.gms.ads.AdSize").RunMethod("getCurrentOrientationAnchoredAdaptiveBannerAdSize", Array(ctxt, width)) Dim jo As JavaObject = res.Native res.Width = jo.RunMethod("getWidthInPixels", Array(ctxt)) res.Height = jo.RunMethod("getHeightInPixels", Array(ctxt)) Return res End Sub 2: Add to Process_Globals Code: Code: Copy Type AdSize (Native As Object, Width As Int, Height As Int) 3. Usage: Code: Code: Copy Dim size As AdSize = GetAdaptiveAdSize adview1.Initialize2("ad", "ca-app-pub-126753333333/948333333", size.Native) Activity.AddView(adview1, 0, 0, size.Width, size.Height) I'm getting this error java.lang.RuntimeException: Method: getCurrentOrientationAnchoredAdaptiveBannerAdSize not found in: com.google.android.gms.ads.AdSize What am i missing?
From code posted by Erel on this thread https://www.b4x.com/android/forum/threads/admob-adaptive-banners.111525/ 1: Code: Code: Copy Sub GetAdaptiveAdSize As AdSize Dim ctxt As JavaObject ctxt.InitializeContext Dim AdSize As JavaObject Dim width As Int = 100%x / GetDeviceLayoutValues.Scale Dim res As AdSize res.Native = AdSize.InitializeStatic("com.google.android.gms.ads.AdSize").RunMethod("getCurrentOrientationAnchoredAdaptiveBannerAdSize", Array(ctxt, width)) Dim jo As JavaObject = res.Native res.Width = jo.RunMethod("getWidthInPixels", Array(ctxt)) res.Height = jo.RunMethod("getHeightInPixels", Array(ctxt)) Return res End Sub 2: Add to Process_Globals Code: Code: Copy Type AdSize (Native As Object, Width As Int, Height As Int) 3. Usage: Code: Code: Copy Dim size As AdSize = GetAdaptiveAdSize adview1.Initialize2("ad", "ca-app-pub-126753333333/948333333", size.Native) Activity.AddView(adview1, 0, 0, size.Width, size.Height) I'm getting this error java.lang.RuntimeException: Method: getCurrentOrientationAnchoredAdaptiveBannerAdSize not found in: com.google.android.gms.ads.AdSize What am i missing?
DonManfred Expert Licensed User Longtime User Nov 20, 2019 #2 Lucas Eduardo said: What am i missing? Click to expand... probably you are using an "old" artifact. 18.3.0 2019‑11‑05 ^^^^ Version where getCurrentOrientationAnchoredAdaptiveBannerAdSize is added to the artifact. Start B4ASDKManager and download all recommended items. Try again. Upvote 0
Lucas Eduardo said: What am i missing? Click to expand... probably you are using an "old" artifact. 18.3.0 2019‑11‑05 ^^^^ Version where getCurrentOrientationAnchoredAdaptiveBannerAdSize is added to the artifact. Start B4ASDKManager and download all recommended items. Try again.