Error when displaying adaptive banner in landscape position

89 views
Skip to first unread message

Diego

unread,
Sep 6, 2024, 4:06:58 PM9/6/24
to Google Mobile Ads SDK Developers
Hello team,

We found that when we rotated our application from Portrait position to Landscape position, the adaptive banner is not being reloaded. The message displayed in Ad Inspector is:

attachment

We downloaded the adaptive banner example from (https://github.com/googleads/googleads-mobile-android-examples/tree/main/kotlin/admob/BannerExample)

and the same error occurs. 

The device tested was a Samsung Galaxy S21.

I found that the problem stopped occurring when I changed the code that calculates the screen width to:

  return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, AdSize.FULL_WIDTH)

According to the message on the forum: https://github.com/googleads/googleads-mobile-unity/issues/1068#issuecomment-1312725741

This update occurred in the Admob version:

22.3.0 2023‑08‑22
Added support for creating adaptive sizes using AdSize.FULL_WIDTH as the width. Previously, ad sizes created using AdSize.FULL_WIDTH would be treated as AdSize.SMART_BANNER.

However, the documentation and examples still perform manual width calculation which appears to fail on some devices.

private val adSize: AdSize
    get() {
      val displayMetrics = resources.displayMetrics
      val adWidthPixels =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
          val windowMetrics: WindowMetrics = this.windowManager.currentWindowMetrics
          windowMetrics.bounds.width()
        } else {
          displayMetrics.widthPixels
        }
      val density = displayMetrics.density
      val adWidth = (adWidthPixels / density).toInt()
      return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth)
    }
Screenshot_20240906_111123_AdMob Banner Example.jpg

Mobile Ads SDK Forum Advisor

unread,
Sep 9, 2024, 5:24:39 AM9/9/24
to sup...@dsmartapps.app, google-adm...@googlegroups.com

Hi,

The code is not updated in GitHub. It is recommended to follow AdSize.FULL_WIDTH as mentioned in release notes

Feel free to reach out to us if you need more help!

 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vFqw2:ref" (ADR-00267138)

Thanks,
 
Google Logo Mobile Ads SDK Team


Reply all
Reply to author
Forward
0 new messages