ez4nick ez4nick - 5 months ago 366
Java Question

Admob Test Ads load, Live Ads will not

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?

Answer

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.

Comments