W/flutter ( 2864): onAdFailedToLoad: 0
I/Ads ( 2864): Ad failed to load : 0
I/flutter ( 2864): BannerAd event is MobileAdEvent.failedToLoad
в чем может быть проблема?
import 'package:flutter/material.dart';
import 'package:firebase_admob/firebase_admob.dart';
const String testDevice = 'Mobile_id';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
MobileAdTargetingInfo targetingInfo;
BannerAd myBanner;
@override
void initState() {
super.initState();
targetingInfo = MobileAdTargetingInfo(
keywords: <String>['flutterio', 'beautiful apps'],
contentUrl: 'https://flutter.io',
birthday: DateTime.now(),
childDirected: false,
designedForFamilies: false,
gender: MobileAdGender
.male, // or MobileAdGender.female, MobileAdGender.unknown
testDevices: <String>[], // Android emulators are considered test devices
);
myBanner = BannerAd(
// Replace the testAdUnitId with an ad unit id from the AdMob dash.
// https://developers.google.com/admob/android/test-ads
// https://developers.google.com/admob/ios/test-ads
adUnitId: BannerAd.testAdUnitId,
size: AdSize.smartBanner,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("BannerAd event is $event");
},
);
}
void _show_banner() {
myBanner
..load()
..show(
anchorOffset: 0.0,
anchorType: AnchorType.bottom,
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Title',
theme: ThemeData(),
home: Scaffold(
appBar: AppBar(
title: Text('data'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
onPressed: () => _show_banner(),
child: Text('Show Banner Ad'),
)
],
),
),
),
);
}
}
так же добавил тег в AndroidManifest.xml
после
<application>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>