I have a flutter app setup to run google ads using the google_mobile_ads package. All packages are the most recent. I configured it for iOS & Android and the test ads are loading on iOS as expected but not on Android 11.0. This is only an issue on Android 11.0 - API R. When run on Android 9.0 - API 28 the test ads load.
My configuration: AndroidManifest.xml
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-MY_APP_ID"/>
initState()
setState(() {
_banner = BannerAd(
adUnitId: 'ca-app-pub-3940256099942544/6300978111',
size: AdSize.fullBanner,
request: AdRequest(),
listener: bannerListener,
)..load();
});
where bannerListener is:
final BannerAdListener bannerListener = BannerAdListener(
onAdLoaded: (Ad ad) => print('Ad loaded.'),
onAdFailedToLoad: (Ad ad, LoadAdError error) {
ad.dispose();
print('Ad failed to load: $error');
},
onAdOpened: (Ad ad) => print('Ad opened.'),
onAdClosed: (Ad ad) => print('Ad closed.'),
);
When I run on Android I get the following error:
AdWidget requires Ad.load to be called before AdWidget is inserted into the tree
If I change the code up to split the ..load() to a different line I then get this error:
I/Ads (11598): Ad failed to load : 0
I/flutter (11598): Ad failed to load: LoadAdError(code: 0, domain: com.google.android.gms.ads, message: Internal error., responseInfo: ResponseInfo(responseId: null, mediationAdapterClassName: , adapterResponses: []))
I'm showing the banner with this code:
if (_banner == null)
SizedBox(height: 20)
else
Container(
height: 50,
child: AdWidget(ad: _banner!),
)
What am I doing wrong that the test Ads won't load on Android but iOS has no issue?