Skip to content
DeveloperMemos

Cutout Display Issue with Interstitial Ads in Google Mobile Ads SDK for Flutter (Android)

Flutter, Google Mobile Ads, Interstitial Ads, Android, Screen Cutouts1 min read

This article describes an issue with interstitial ads in the Google Mobile Ads SDK for Flutter. The issue arises on devices with cutouts at the top of the screen, such as notches. When an interstitial ad is displayed on these devices, it does not encompass the entire screen. This can lead to the ad being flagged for violating Google's ad policies. It's kind of disappointing considering that Google maintains the repository themselves, getting ad violations for using a officially supported package is quite ridiculous(I'll leave it at that for now).

Workaround

A workaround is to adjust the Android theme used by the Flutter application. This entails incorporating a line into the theme file. The Flutter team is also apparently developing a permanent fix.

Code Snippet

Here's an example of how this might be implemented(you can also see some discussion in this GitHub issue):

1<!-- You can name this style whatever you'd like -->
2<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
3 <item name="android:windowBackground">@drawable/launch_background</item>
4
5 <item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="27">
6 never
7 </item>
8</style>

In the above example, android:windowLayoutInDisplayCutoutMode" is added to the theme. This instructs the Android system specifically not to show the window for the Activity in cut out mode. You can edit this in the 'styles.xml' file of your Android project - or create a new theme and apply it yourself it's upto you.

In Closing

The workaround described above should prevent interstitial ads from being flagged for violating Google's ad policies on devices with screen cutouts for the time being. In the GitHub issue it says the Flutter team is working on a fix but I checked the issue they linked and it has been closed with the last comment being "From triage: Closing as working as intended"... Which isn't very encouraging.