在onRewardedAdClosed()之后如何解决admob错误? [英] How to solve the error admob after onRewardedAdClosed()?

查看:42
本文介绍了在onRewardedAdClosed()之后如何解决admob错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The ad is showing, but when I click on close the ad the error is:

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

Test real mobile: Android 6.0, Huawei 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

推荐答案

将第一部分保留在此处,以防它对其他人有帮助

Leaving this first part here in case it can help anybody else

您首先需要分离Webview:

You first need to detach the Webview:

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

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

Try Something Like that, any other help you need you can just shout

编辑

尝试类似的方法,因为错误表明adview存在问题

Try something like this as the errors indicate there is a problem with the adview

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

将此添加到您的oncreateM

Add this to your 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);

这篇关于在onRewardedAdClosed()之后如何解决admob错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆