gpt4 book ai didi

java - 如何解决onRewardedAdClosed()后admob错误?

转载 作者:行者123 更新时间:2023-12-02 09:25:08 24 4
gpt4 key购买 nike

广告正在展示,但当我点击关闭广告时,错误为:

W/Ads: #004 The webview is destroyed. Ignoring action.
W/Ads: #004 The webview is destroyed. Ignoring action.
W/Ads: #004 The webview is destroyed. Ignoring action.
#004 The webview is destroyed. Ignoring action.

并且操作不会在 onRewardedAdClosed()

中执行

步骤:

启动时,我执行:

MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
Log.d(TAG, "onInitializationComplete: " + initializationStatus);
}
});

下一个:

rewardedAd = new RewardedAd(this, "ca-app-pub-3940256099942544/5224354917");

下一个:

RewardedAdCallback adCallback = new RewardedAdCallback() {
@Override
public void onRewardedAdOpened() {
// Ad opened.
}

@Override
public void onRewardedAdClosed() {
// Ad closed.
Log.d(TAG, "onRewardedAdClosed: ");

fragmentFirst = new FragmentFirst();

clipBody = getSupportFragmentManager();
FragmentTransaction clipUnit = clipBody.beginTransaction();

clipUnit.add(R.id.container, fragmentFirst, "fragment_first");
clipUnit.addToBackStack(null);
clipUnit.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
clipUnit.commit();
}

@Override
public void onUserEarnedReward(@NonNull RewardItem reward) {
// User earned reward.
// Load Tasks
Log.d(TAG, "onUserEarnedReward: ");

// coins++
}

@Override
public void onRewardedAdFailedToShow(int errorCode) {
// Ad failed to display
}
};
rewardedAd.show(MainActivity.this, adCallback);

测试真实手机:Android 6.0、华为p8 Lite

implementation 'com.google.android.gms:play-services-ads:18.2.0'

尝试降级 com.google.android.gms: play-services-ads,但不起作用

问题是什么?

编辑

日志:

E/Ads: Google Mobile Ads SDK initialization functionality unavailable for this session. Ad requests can be made at any time.
E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)
E/chromium: [ERROR:gl_surface_egl.cc(222)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
E/Ads: Invalid event ID: null
java.lang.NumberFormatException: null

最佳答案

将第一部分留在这里,以防对其他人有帮助

您首先需要分离 Webview:

webViewPlaceholder.removeView(myWebView);
myWebView.removeAllViews();
myWebView.destroy();

尝试类似的方法,您需要的任何其他帮助都可以大喊

编辑

尝试类似的操作,因为错误表明广告 View 存在问题

public void onDestroy()
{
adView.removeAllViews();
adView.destroy();
super onDestroy();
}

将其添加到您的 oncreateM

mobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);

关于java - 如何解决onRewardedAdClosed()后admob错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58393279/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com