Admob ads not showing up

Viewed 36534

I am trying to implement Admob in Android and I am seeing requests coming into AdMob. However, I am not seeing the Admob ads being displayed on the Android screen in the emulator and my Android test phones as well.

As stated before, I can see the requests coming into my AdMob account. However, the content is not being shown. Is there something that needs to be enabled in my account, the main.xml, AndroidManifest.xml, or in the loading of the application?

My application configuration and code are below. Please advise on what is needed. Thanks!

AndroidManifest:

          <meta-data 
            android:value="My Publisher ID"
            android:name="ADMOB_PUBLISHER_ID" />
        <activity android:name="com.admob.android.ads.AdMobActivity"/>
        <receiver 
            android:name="com.admob.android.ads.analytics.InstallReceiver"
            android:exported="true">
         <intent-filter>
         <action android:name="com.android.vending.INSTALL_REFERRER"/>
         </intent-filter>
         </receiver>
         <meta-data 
             android:value="true" 
             android:name="ADMOB_ALLOW_LOCATION_FOR_ADS"/>

main:

 <com.google.ads.AdView
    android:id="@+id/adView"
   android:layout_alignParentBottom="true"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitId="My Publisher ID"
    ads:loadAdOnCreate="true"/>

On Create Code:

        AdView adView = (AdView)this.findViewById(R.id.adView);
        AdRequest re = new AdRequest();
        re.setTesting(true);
        adView.loadAd(re);

Any help is appreciated!!

14 Answers
  1. Go to app settings on admob.com and make sure use location data for ads is turned off if your app is not a location based app.

    Use location data for ads is used to filter ads based on location and works only on app with location permission granted. If app does not use location permission, ads will not show.

  2. Make sure your have filled payment details

I see there are two problems in your code based on what you posted:-

  1. The <metadata> section should contain the ADMOB_APP_ID instead of your publisher ID. This should be declared under <application> tag in ApplicationManifest.xml.

    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="[ADMOB_APP_ID]"/>
    

    you can find ADMOB_APP_ID by on ADMOB dashboard, click on the application
    and check "App Settings". You can see the APP_ID which starts
    typically with ca-app-pub-0123456789012345.

  2. The second problem is, where you have declared AdView in your layout. Remember you have to provide Ad unit not your publisherID, which you can create in ADMOB dashboard by clicking on Ad Unit tab
    under your application. Put the correct "ad unit" against your AdView as below.

    ads:adUnitId="ca-app-pub-3940256099942544/6300978111" <!-- remember this is adUnit not App ID and this value above is for test banner Ad. -->
    

Once you have fixed above problems, do the following:-

MobileAds.initialize(this, "YOUR_ADMOB_APP_ID"); in onCreate of your first Activity. This needs to be done only once and thus the right place is either your first activity or at application's onCreate callback.

Find the AdView in the activity onCreate where you have included AdView in the layout.

mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);

Test Ads work by providing test adunit published by google.

mAdView.setAdSize(AdSize.BANNER);
mAdView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");

Additionally, if you want to handle Ad events, do as follows:-

mAdView.setAdListener(new AdListener() {
    @Override
    public void onAdLoaded() {
        // Code to be executed when an ad finishes loading.
    }

    @Override
    public void onAdFailedToLoad(int errorCode) {
        // Code to be executed when an ad request fails.
    }

    @Override
    public void onAdOpened() {
        // Code to be executed when an ad opens an overlay that
        // covers the screen.
    }

    @Override
    public void onAdLeftApplication() {
        // Code to be executed when the user has left the app.
    }

    @Override
    public void onAdClosed() {
        // Code to be executed when when the user is about to return
        // to the app after tapping on an ad.
    }
});

This is because admin inventory requires some requests to be generated to check that the app can make some profit!

Please let setup the ads properly and publish the app, after about 1k requests are made, the ads will automatically show up!

I too was suffering from this problem and got my answer when I published my own app!

If admob "App Id" and "Unit Id" is correct then upload on google play store it will show the add. I was facing same type of issue but after upload on google play it resolve automatic.

My ads were shown by just having few request here are the following steps I made

  1. Get More Requests You are saying that 400 imp but no ads just make another ad unit in same app it will start showing I also did this this method and ad started In my previous ad unit it have many request but no imp then I made another unit it started showing ads

  2. Have patient in my account it take 4 days to show ads and my account was approved by Google in 1 hr it take a lot of time to build inventory in the server so be patient you will have your ads

  3. Complaint Google at admob complatint they will check your app and chances of app is approved is 50-50%

Related