我正在尝试在我的Flutter应用中实施Google Admob,但是没有任何效果。我遵循了admob软件包(https://pub.dev/packages/firebase_admob)中的文档以及一些youtube教程,但是每次遇到此错误时,都会出现此错误。
onAdFailedToLoad:0,MobileAdEvent.failedToLoad
您是否认为admobs仪表板有问题?因为代码0表示某种内部错误。但是我不知道那会是什么。
这是我的代码
Widget build(BuildContext context) {
FirebaseAdMob.instance.initialize(appId: "app-id").then((v) {
myBanner..load()..show();
});
...
// end of class
MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
keywords: <String>['games', 'pubg'],
contentUrl: 'https://flutter.io',
childDirected: false,
testDevices: <String>[],
);
BannerAd myBanner = BannerAd(
adUnitId: BannerAd.testAdUnitId,
size: AdSize.smartBanner,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("BannerAd event is $event");
},
);
// androidmanifest.xml
...
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="app-id"/>
...
感谢您的建议!