Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After updating Google Ads SDK onAdFailedToLoad is deprecated, How to resolve?

After updating Google Ads SDK to 19.3.0 gives a deprecated warning message for onAdFailedToLoad(). How can I resolve this?

My code:

public void BannerAdMob() {
        final AdView adView = findViewById(R.id.adsView);
        adView.loadAd(new AdRequest.Builder().build());
        adView.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                
            }

            @Override
            public void onAdFailedToLoad(int error) { // this method is deprecated 
                
            }
        });
    }
like image 373
Attaullah Avatar asked Jul 26 '20 17:07

Attaullah


1 Answers

They added a new method you should override instead of that one:

public void onAdFailedToLoad (LoadAdError adError)

You can get a bunch of information from the adError object, calling getCode() on it will give you the code that the old method had.

like image 170
Ralgha Avatar answered Sep 28 '22 12:09

Ralgha