Uncaught Exception Thrown By Finalizer: All Webview Methods Must Be Called On The Same Thread. (expected Looper )
I am using Admob sdk 18.1.1 and getting error Uncaught exception thrown by finalizer java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'Finaliz
Solution 1:
this issue is mostly caused because you're using interstitial ads. because i had the same issue and google refused any update i made for the app until i "fixed" the issue.
the problem here, is that interstitial ads will try to load also when you exit the app tapping on the home button.
so you have to block the ads from loading when you leave the app.
you can try this (what i have done):
in your activiy/fragment create a field variable, like
private boolean shouldLoadAds
;
in your onCreate() you initialise your Interstitial:
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd .setAdUnitId(getString(R.string.adview_interstitial));
mInterstitialAd .loadAd(new AdRequest.Builder().build());
and when you call the interstitial to show it, you do it like this:
if(mInterstitialAd != null && mInterstitialAd .isLoaded()) {
mInterstitialAd .show();
mInterstitialAd .setAdListener(new AdListener(){
@Override
public void onAdClosed() {
super.onAdClosed();
if(shouldLoadAds) { //load the ad only if shouldLoadAds == true
mInterstitialAd .loadAd(new AdRequest.Builder().build());
}
//here some code, what should be done, after the ads is cloded
}
});
}
then you have to override onStart()
and on onStop()
like this:
@OverridepublicvoidonStart() {
super.onStart();
shouldLoadAds= true;
}
@OverridepublicvoidonStop() {
shouldLoadAds= false;
super.onStop();
}
Post a Comment for "Uncaught Exception Thrown By Finalizer: All Webview Methods Must Be Called On The Same Thread. (expected Looper )"