Reputation: 10199
I'm trying to implement admob ads as follows:
MobileAds.initialize(getApplicationContext(), getString(R.string.banner_ad_unit_id));
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
when I use the test device ID I can see the test ad, however when I use the above code the ad is not visible. This is the log I see when the above code runs:
06-14 17:15:15.486 23521-23521/com.nick.app I/Ads: Starting ad request.
06-14 17:15:15.487 23521-23521/com.nick.app I/Ads: Use AdRequest.Builder.addTestDevice("**********************") to get test ads on this device.
06-14 17:15:18.356 23521-23521/com.nick.app E/Ads: JS: Uncaught ReferenceError: AFMA_ReceiveMessage is not defined (:1)
06-14 17:15:18.449 23521-23521/com.nick.app I/Ads: Ad finished loading.
06-14 17:15:18.477 23521-23521/com.nick.app E/Ads: JS: Uncaught ReferenceError: AFMA_ReceiveMessage is not defined (:1)
Any suggestions for this?
Upvotes: 1
Views: 1000
Reputation: 1382
MobileAds.initialize(getApplicationContext(), getString(R.string.banner_ad_unit_id));
This above code should not contain the banner ad unit id. You should place YOUR_ADMOB_APP_ID as a second parameter as givern below
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
Upvotes: 0
Reputation: 10199
It turns out that adUnitID
in my AdView
defined in my xml layout needed to match what was defined in my Activity where I was defining the ad.
Upvotes: 0
Reputation: 165
This happened to me too at first, you have to wait a little bit. It should show within a few hours, probably less.
Upvotes: 1