I am using google_mobile_ads
Flutter package (version ^3.0.0
) in a Flutter app targeting Android. I am occasionally getting ANRs that could be related to ads.
This article talks about optimizing Google mobile ads initialization and loading on Android as a way to prevent ANRs.
Should I add these options to my Android manifest considering I am using Flutter and not a native Android app that the article is targeting?
<manifest>
...
<application>
...
<meta-data
android:name="com.google.android.gms.ads.flag.OPTIMIZE_INITIALIZATION"
android:value="true"/>
<meta-data
android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING"
android:value="true"/>
</application>
</manifest>
2
Answers
Considering
google_mobile_ads
Flutter package does use the Google Mobile Ads SDK for Android, those optimizations should apply.As described here, activating those optimizations means the initialization and ad loading tasks that require extended processing time are offloaded to background threads.
This thread does not mention any drawback, and refer to this "Get started" guide.
That means it is not the default only because those optimizations are still in Beta.
The new testing features for ad inspector announced yesterday can help you validate those optimizations effects.