如何解决AdMob 奖励广告在我的 Android 模拟器上崩溃
我的主要活动:
//init ads & load
MobileAds.initialize(getApplicationContext(),new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
//on initalized
}
});
loadRewardedAd()
private void loadRewardedAd() {
RewardedAd.load(getApplicationContext(),ADS_REWARDED_ID,new AdRequest.Builder().build(),new RewardedAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
super.onAdLoaded(rewardedAd);
//loaded
adsRewarded = rewardedAd;
//listener
adsRewarded.setFullScreenContentCallback(new FullScreenContentCallback() {
@Override
public void onAdFailedToShowFullScreenContent(AdError adError) {
super.onAdFailedToShowFullScreenContent(adError);
//Failed
adsRewarded = null;
loadRewardedAd();
}
@Override
public void onAdShowedFullScreenContent() {
super.onAdShowedFullScreenContent();
//showed
adsRewarded = null;
loadRewardedAd();
}
@Override
public void onAddismissedFullScreenContent() {
super.onAddismissedFullScreenContent();
//dismissed
}
});
}
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
super.onAdFailedToLoad(loadAdError);
//Failed
adsRewarded = null;
}
});
}
有时当 onAdLoaded() 运行时,它会立即崩溃。但这仅发生在我的 Android 模拟器上。虽然我的手机是 Android 10(与模拟器相同),但我没有看到任何崩溃。我没有收到任何警告,logcat 只是发出内存泄漏警告。
崩溃日志:
https://paste.ubuntu.com/p/5WPZhkTknp/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。