Issue
I am using android Studio 2021.1 and strangely after updating my libraries earlier I get this error when I compile my application incompatible types: String cannot be converted to OnInitializationCompleteListener
MobileAds.initialize(this, getString(R.string.admob_banner_id));
mAdView = findViewById(R.id.adView); //The line that returns the error to me
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Solution
Apparently google has changed the way of integrating ads into apps. I went to the site and applied the new rules to my code and everything was back to normal.
For those who will encounter the same problem simply replace your code with this one
AdView adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(getString(R.string.admob_banner_id));
Answered By - idris
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.