Skip to content

bug: Android banner safe-area issues with Capacitor 8.5.2+ and different WebView versions #468

Description

@luisbytes

Describe the bug

After upgrading to Capacitor 8.5.2, the AdMob banner can have incorrect safe-area behavior depending on the Android version and Android System WebView version.

The issue can be reproduced with the standard adaptive banner configuration:

await AdMob.showBanner({
  adId: BANNER_AD_UNIT_ID,
  adSize: BannerAdSize.ADAPTIVE_BANNER,
  position: BannerAdPosition.BOTTOM_CENTER,
  isTesting: true,
});

This appears to be related to the safe-area / edge-to-edge changes introduced in Capacitor 8.5.2.

Capacitor 8.5.2 requirement

With Capacitor 8.5.2, EdgeToEdge.enable(this) also needs to be added to MainActivity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    EdgeToEdge.enable(this);
}

Without this configuration, the application can have unexpected safe-area behavior.

The reproduction project already includes the required configuration and is ready to run:

https://github.com/luisbytes/admob-safearea-community

Capacitor 9

This is also relevant for Capacitor 9.

The Capacitor 9 changes that make edge-to-edge the default in the Android starter template and update the migration path for existing projects are already merged into next:

These changes make EdgeToEdge.enable(this) part of the Android MainActivity template and update existing projects to the new edge-to-edge configuration.

However, this issue should also be patched for Capacitor 8.5.2+ and not be deferred until Capacitor 9. Projects using Capacitor 8.5.2 or later are already affected by this behavior today.

Because of this, it would be useful for @capacitor-community/admob to provide a fix for the current Capacitor 8.5.2+ behavior while also ensuring compatibility with the Capacitor 9 changes.

To Reproduce

  1. Open the reproduction project:
    https://github.com/luisbytes/admob-safearea-community
  2. Install the dependencies and run the Android application.
  3. The project is already configured with Capacitor 8.5.2 and the required EdgeToEdge.enable(this) configuration.
  4. Test the application using different Android System WebView versions.
  5. Observe the position of the bottom adaptive AdMob banner.

The following behavior can be reproduced:

Android WebView Result Screenshot
Android <= 14 WebView < 140 Works Image
Android <= 14 WebView >= 140 Banner is behind the navigation bar Image
Android >= 15 WebView < 140 Double safe-area padding Image
Android >= 15 WebView >= 140 Works Image

Expected behavior

The banner should always be positioned correctly above the Android navigation/gesture area without being covered or receiving the safe-area inset twice, regardless of the Android System WebView version.

Smartphone

  • OS: Android 14 / Android 16
  • WebView: 113 / 134 / 153
  • Capacitor: 8.5.2
  • AdMob: @capacitor-community/admob
  • Ad size: BannerAdSize.ADAPTIVE_BANNER
  • Position: BannerAdPosition.BOTTOM_CENTER
  • Testing: true

Additional context

The important factor appears to be the Android System WebView version, rather than Android version alone.

The issue appears to be related to the safe-area / edge-to-edge refactor introduced in Capacitor 8.5.2 (ionic-team/capacitor#8535).

It would be good to address this in the current Capacitor 8 line rather than waiting for Capacitor 9, because applications using Capacitor 8.5.2+ can already encounter this issue depending on their Android System WebView version.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions