Flutter 我正在尝试显示我在admob中使用其ID创建的广告
它完全可以与TestAdId一起工作,但是当我输入我自己的成人信息时,它给出了以下错误。 这将是感激的,使广告出现在之间的职位内的listview。。。 一切都设置妥当唯一的问题是使用真正的成人。 我被困在这4天,你的帮助将不胜感激 错误Flutter 我正在尝试显示我在admob中使用其ID创建的广告,flutter,dart,Flutter,Dart,它完全可以与TestAdId一起工作,但是当我输入我自己的成人信息时,它给出了以下错误。 这将是感激的,使广告出现在之间的职位内的listview。。。 一切都设置妥当唯一的问题是使用真正的成人。 我被困在这4天,你的帮助将不胜感激 错误 Exception has occurred. PlatformException (PlatformException(load_failed_ad, cannot reload a failed ad, id=71281197, null)) **co
Exception has occurred.
PlatformException (PlatformException(load_failed_ad, cannot reload a failed ad, id=71281197, null))
**code**
class Car extends StatefulWidget {
@override
_CarState createState() => _CarState();
}
class _CarState extends State<Car> {
static String adId = 'ca-app-pub-xxxxxx2680942917/5470xxxxxx';
String appId = 'ca-app-pub-xxxxxx2680942917~6128xxxxxx';
MobileAdTargetingInfo targetingInfo;
BannerAd myBanner;
@override
void initState() {
super.initState();
FirebaseAdMob.instance.initialize(appId: appId);
myBanner = createBannerAd()..load();
MobileAdTargetingInfo(
keywords: <String>['flutterio', 'beautiful apps'],
contentUrl: 'https://flutter.io',
childDirected: false,
//testDevices: <String>[],
);
}
BannerAd createBannerAd() {
return BannerAd(
adUnitId: adId,
size: AdSize.fullBanner,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("BannerAd event $event");
},
);
}
showBanner() {
myBanner ??= createBannerAd();
myBanner
..load()
..show(
// Positions the banner ad 60 pixels from the bottom of the screen
anchorOffset: 0.0,
// Positions the banner ad 10 pixels from the center of the screen to the right
horizontalCenterOffset: 0.0,
// Banner Position
// anchorType: AnchorType.bottom,
);
}
@override
Widget build(
BuildContext context,
) {
return SafeArea(
child: Scaffold(
backgroundColor: Colors.teal[50],
body: StreamBuilder(
stream: Firestore.instance.collection('car').snapshots(),
builder: (context, snapshot) {
if (snapshot.data == null)
return Center(
child: CircularProgressIndicator(
backgroundColor: Colors.red,
valueColor: new AlwaysStoppedAnimation<Color>(Colors.teal),
),
);
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) => SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
//AD
(showBanner() != null) ? showBanner() : Container(),
...
发生异常。
PlatformException(PlatformException(加载失败的ad,无法重新加载失败的ad,id=71281197,null))
**代码**
类Car扩展StatefulWidget{
@凌驾
_CarState createState()=>\u CarState();
}
类_CarState扩展了状态{
静态字符串adId='ca-app-pub-XXXXXX 2680942917/5470xxxxxx';
字符串appId='ca-app-pub-xxxxxx 2680942917~6128xxxxxx';
MobileAdTargetingInfo targetetinginfo;
班纳拉德·米班纳;
@凌驾
void initState(){
super.initState();
FirebaseAdMob.instance.initialize(appId:appId);
myBanner=createBannerAd()…load();
移动目标信息(
关键词:['flatterio','beautiful apps'],
contentUrl:'https://flutter.io',
孩子:错,
//测试设备:[],
);
}
BannerAd createBannerAd(){
返回横幅(
阿杜尼提德:阿迪德,
大小:AdSize.fullBanner,
targetingInfo:targetingInfo,
侦听器:(MobileAdEvent事件){
打印(“BannerAd事件$event”);
},
);
}
showBanner(){
myBanner???=createBannerAd();
我的旗帜
…加载()
…展示(
//将横幅广告放置在距屏幕底部60像素的位置
主持人偏移:0.0,
//将横幅广告从屏幕中心向右放置10个像素
水平中心偏移:0.0,
//旗帜位置
//anchorType:anchorType.bottom,
);
}
@凌驾
小部件构建(
构建上下文上下文,
) {
返回安全区(
孩子:脚手架(
背景颜色:颜色。青色[50],
正文:StreamBuilder(
流:Firestore.instance.collection('car').snapshots(),
生成器:(上下文,快照){
如果(snapshot.data==null)
返回中心(
子对象:循环压缩机指示器(
背景颜色:Colors.red,
valueColor:new AlwaysStoppedAnimation(Colors.teal),
),
);
返回ListView.builder(
itemCount:snapshot.data.documents.length,
itemBuilder:(上下文,索引)=>SingleChildScrollView(
孩子:填充(
填充:边缘设置。全部(8.0),
子:列(
儿童:[
//广告
(showBanner()!=null)?showBanner():容器(),
...