How to solve the error admob after onRewardedAdClosed()?

Viewed 2552

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.

And actions don't perform in onRewardedAdClosed()

Steps:

When starting, I execute:

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

Next:

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

Next:

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);

Test real mobile: Android 6.0, Huawei p8 Lite

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

Tried to downgrade com.google.android.gms: play-services-ads, but it doesn't work

What is the problem?

Edits

Log:

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
2 Answers

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

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

Edits

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

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

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);

I had the same symptoms and message : W/Ads: #004 The webview is destroyed. Ignoring action.

In my case, it was because the code of mainActivity.

@Override
protected void onUserLeaveHint() {
    finish();
    super.onUserLeaveHint();
}

"finish();" in the code makes app "finish" if ad video closed. After deleting that one line, my app worked fine.

Related