Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onFailedToRecieveAd(Invalid Ad Request) message with AdMob

Tags:

android

admob

I've been trying to get AdMob to work for some time on my app. I keep getting onFailedToRecieveAd(Invalid Ad Request) message in the log. I've paired down my test application to this:

  AdView adView;
   LinearLayout ll;

   public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
    adView = new AdView(this, AdSize.BANNER, "pub-2...............");//inserted my 16 digit pub id here
    adView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);

    ll = new LinearLayout(this);  
    ll.setOrientation(LinearLayout.VERTICAL);  

    ll.addView(adView); 
    setContentView(ll); 
    AdRequest adRequest = new AdRequest();

    adRequest.addTestDevice("3...............");// 16 digits, tried other strings as 
   // follows:

   //for addTestDevice I've tried several numbers, including the 16 digit device
  // number given me by my "device id" application, the "0123456789ABCDEF" device number
  // given by my console and device windows, the "CECE.........................." 32 digit
 // device number my logcat file told me to use in a logcat message, 
  //  "AdRequest.TEST_EMULATOR"
  // which an admob example in the docs said to use, "9774d56d682e549c" which another 
  //  admob docs example said to use.

     adView.loadAd(adRequest);

I've also tried adView.loadAd(new AdRequest()); using no device id as in another one of the google admob example apps.

nothing has worked to show anything, it's not even creating space for the ad, just the onFailedToRecieveAd(Invalid Ad Request) message in the logcat

I've also included the necessary permissions and "com.google.ads.AdActivity" in the manifest.

like image 756
Androidcoder Avatar asked Aug 27 '13 14:08

Androidcoder


2 Answers

Wow, after days of frustration and posts to various forums I've found the answer.

You have to go to your account on the Admob website to set up your specific app for the admob ads and get a new longer publisher number. My publisher number only started with 'pub-......' where my new number is longer and starts with 'ca-app-pub-.......'. I was curious about this from the start when I saw the 'ca-app-pub' preface in an example banner ap.

Nowhere on the Google Admob "Google Mobile Ads SDK" development site in the "banner ads 1" instructions (https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals?hl=en_US#android) does it mention having to go back to your admob account to set up your specific app for ads and get a new publisher number.

The stupid mistakes are the hardest to fix.

like image 96
Androidcoder Avatar answered Sep 25 '22 15:09

Androidcoder


Be carefull with the id, there are 2 codes: the editor number (like this: pub-xxxxxxxxxxxxxxxx) and the other is the banner id (like this: ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx) (this one you need to use)

You need to use the last one, if you use the first doesnt work:)

like image 32
cinic Avatar answered Sep 24 '22 15:09

cinic