我正在构建Flutter应用,并尝试使用firebase_admob flutter插件添加Admob广告。一切正常,测试广告正确加载。但是,当用户单击广告(横幅广告或非页内广告)时,广告会导航到所点击广告的网址。当用户返回到应用程序时,该应用程序已崩溃并变得无响应。
我的问题是,仅当使用Google提供的测试广告单元ID时,才会发生这种崩溃行为吗?
以下是我的广告设置: 对于横幅广告:
static void setBannerAd() {
_bannerAd = BannerAd(
//The ff Ad unit id is for test purpose obtained from google
adUnitId: 'ca-app-pub-3940256099942544/6300978111',
size: AdSize.banner,
//targetingInfo: _getMobileAdTargetingInfo(),
listener: (MobileAdEvent event) {
print("BannerAd event is $event");
},
);
}
对于非页内广告
static void showInterstitialAd() {
var interstitialAd = InterstitialAd(
//The ff Ad unit id is for test purpose obtained from google
adUnitId: 'ca-app-pub-3940256099942544/1033173712',
//targetingInfo: _getMobileAdTargetingInfo(),
listener: (MobileAdEvent event) {
print("InterstitialAd event is $event");
},
);
interstitialAd
..load()
..show(anchorOffset: 0.0, anchorType: AnchorType.bottom);
}
static MobileAdTargetingInfo _getMobileAdTargetingInfo() {
return MobileAdTargetingInfo(
keywords: <String>['placeholder1', 'placeholder2'],
//contentUrl: 'https://whatsthatflower.com/',
childDirected: false,
//testDevices: <String>["4SDFE456UIINGFGJJK567"],
);
}
应用崩溃后,用户尝试使用Flutter应用后返回了以下内容:
E/EGL_emulation(13994): tid 14031: swapBuffers(517): error 0x300d (EGL_BAD_SURFACE)
E/EGL_emulation(13994): egl_window_surface_t::swapBuffers called with NULL buffer
E/EGL_emulation(13994): tid 14031: swapBuffers(517): error 0x300d (EGL_BAD_SURFACE)
这是正常行为还是我做错了什么?谢谢