我尝试重新加载奖励视频广告,当我打电话时RewardedVideoAd.instance.load(adUnitId: "xxx", targetingInfo: xyz);
发现以下错误:
W/MessageQueue(13672): 处理程序 (android.os.Handler) {1a13e8a} 向死线程上的处理程序发送消息 W/MessageQueue(13672): java.lang.IllegalStateException: 处理程序 (android.os.Handler) {1a13e8a向死线程上的处理程序发送消息 java:1496) W/MessageQueue(13672): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) W/ExoPlayerImplInternal(13672): 发布后发送消息(1)。消息被忽略。D/Graph (13672): removeVertex() : insertDummyVertex,因为没有祖先。D/ViewRootImpl@b8db50eAdActivity: mHardwareRenderer.destroy()#4 D/ViewRootImpl@b8db50eAdActivity: dispatchDetachedFromWindow
我将听众放在initState()
我的屏幕上。在这个屏幕上,我有一个button
地方,如果我们点击它,它应该会显示 Rewarded Video Ads
。
此外,在Rewarded Ads
重新加载时出现错误后,点击按钮显示广告后出现以下错误(因为 ads 实例为null):
E/flutter (13672): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] 未处理异常:PlatformException(ad_not_loaded, 奖励视频显示失败,未加载广告,null) E/flutter (13672): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7) E/flutter (13672): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33 ) E/flutter (13672): E/flutter (13672): #2 _invokeBooleanMethod (package:firebase_admob/firebase_admob.dart:518:61) E/flutter (13672): E/flutter (13672): #3 RewardedVideoAd.show (包:firebase_admob/firebase_admob.dart:392:12)
我放在Rewarded Video Ads Listener
,initState()
下面是代码:
@override
void initState() {
super.initState();
...
RewardedVideoAd.instance.listener =
(RewardedVideoAdEvent event, {String rewardType, int rewardAmount}) {
if (event == RewardedVideoAdEvent.completed) {
setState(() {
print ("::debug:: ads should be reloaded");
RewardedVideoAd.instance.load(adUnitId: "ca-app-pub-3940256099942544/5224354917", targetingInfo: targetingInfos);
});
}
};
...
onPressed
但是,如果我将代码放在下面的按钮上,视频广告将在点击 2-3 次后显示(在调试时显示ads = null
)
RaisedButton(
onPressed: () {
RewardedVideoAd.instance.show().whenComplete(() {
RewardedVideoAd.instance.load(adUnitId: "ca-app-pub-3940256099942544/5224354917", targetingInfo: targetingInfos);
})
},
...
任何想法 ?
提前致谢...