question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

google_mobile_ads SafeArea override

See original GitHub issue

Steps to Reproduce

This one is a bit complicated, not sure if I am doing something wrong or if it is a bug or just how things are supposed to work. I need some help here please!

I have a rewarded ad displayed in my app. This is implemented pretty vanilla way and it does work, the video ad plays across the entire screen. But there are some weird things happening to the application behind the ad which you cannot really see unless you have a phone with a notch (Samsung A20 in my case).

When the ad runs on a phone with a notch, the ad respects the SafeArea and does not cover the top part of the screen which is normally taken by Android status bar. But it seems that the ad affects the application, so application no longer respects SafeArea and it stretches over all the way to the top of the screen. So you can see the sliver of the app behind the ad, in the area where status bar normally is. I mean it is not the end of the world, but it looks ugly.

So in a nutshell, when the ad starts, it changes the way application behind is displayed which you mostly would not notice except if there is a notch (or you use media query to resize things).

Is this normal? Am I doing something wrong? How to avoid this ugly glitch?

Expected results: App is not visible behind the ad

Actual results: Sliver of the app visible around the notch in “unsafe area”

Code sample
Logs
[√] Flutter (Channel beta, 3.3.0-0.5.pre, on Microsoft Windows [Version 10.0.19044.1949], locale en-US)
    • Flutter version 3.3.0-0.5.pre on channel beta at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 096162697a (9 days ago), 2022-08-22 15:34:14 -0700
    • Engine revision ad3d868e0d
    • Dart version 2.18.0 (build 2.18.0-271.7.beta)
    • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at C:\Users\dejan\AppData\Local\Android\sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.2)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.3.32819.101
    • Windows 10 SDK version 10.0.22000.0
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these
      components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] VS Code (version 1.70.2)
    • VS Code at C:\Users\dejan\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.46.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19044.1949]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 98.0.4758.80
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 104.0.1293.70

[√] HTTP Host Availability
    • All required HTTP hosts are available

image

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
darshankawarcommented, Sep 2, 2022

Thanks for the code sample. Using it, I was able to replicate the behavior using Pixel emulator that has a notch.

Maybe similar / related: https://github.com/googleads/googleads-mobile-flutter/issues/191

0reactions
sharyer-Ilyas-Khancommented, Nov 3, 2022

issue can be resolved by adding below line <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item> <item name="android:windowBackground">?android:colorBackground</item> in android/app/src/main/res/values/style.xml.

Read more comments on GitHub >

github_iconTop Results From Across the Web

iPhone X Ad Rendering | Mobile Ads SDK for iOS
Banner ads must be placed in the "Safe Area" to avoid being obscured by rounded corners, sensor housing, ... override func viewDidLoad() {...
Read more >
testDeviceId's are not working in google-mobile-ads flutter
So setting up for test device are not working and I can't test with real ads. As I'm passing testDeviceId's this log was...
Read more >
How do I position smart banner at top of the Safe area ...
currently the docs only state how to position on botttom of safe area for a smart banner , im unsure of what values...
Read more >
Integrate Adaptive Banner with Xcode - Google Codelabs
... Import the GoogleMobileAds framework; Initialize the Mobile Ads SDK ... Override point for customization after application launch. GADMobileAds.
Read more >
A Flutter Plugin for the Google Mobile Ads SDK - Morioh
Integrating Google Mobile Ads SDK into a Flutter app, which you will do here, ... Map; class NativeAdFactoryExample implements NativeAdFactory { @Override ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found