52
votes

I'm using admob for showing android ads. The test ads are working fine but real ads are not shown. Also, I've no issue with real interstitial ads as they work fine. Just the real banner ads are not showing up. My java code is

private InterstitialAd interstitial;    
interstitial = new InterstitialAd(MainActivity.this);

        interstitial.setAdUnitId("ca-app-pub-********");

        AdView adView = (AdView) this.findViewById(R.id.adView);               
        AdRequest adRequest = new AdRequest.Builder()

        // Add a test device to show Test Ads
         .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
         .addTestDevice("4CCC00EF4EA205A6FE82E1AEB26B0839")
                .build();

        // Load ads into Banner Ads
        adView.loadAd(adRequest);

        // Load ads into Interstitial Ads
        //interstitial.loadAd(adRequest);

The Layout file is

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-********" />

</LinearLayout>
15
Post AndroidManifest.xml. Post build.gradle.Jared Burrows
Did you ever find a solution as I'm having the exact same problem?Shredder2794
finally hows you solved your issue?himCream
Could you resolve the issue?aricherca
I think you don't need to add anything to your layout file, if you are using intersitial ads.Piotr Sagalara

15 Answers

53
votes

When apps are newly registered with AdMob, it takes some time and a few ads requests to allow inventory to build. Because of this, you may not see live impressions immediately. Once your app starts making more requests, you should see more consistent results. Please note that test ads operate through the same channels as live ads. Being able to return a test ad ensures that your application is communicating properly with our network. Be patience it will work after some days.

17
votes

Remove the line that says

.addTestDevice("4CCC00EF4EA205A6FE82E1AEB26B0839")

Also, when you use a virtual device, it shows the test ads no matter what. Are you testing it on a real device?

11
votes

You might be using the sample unit id: ca-app-pub-3940256099942544/6300978111

If you use above then you will see test ads.

Make sure you change to your own unit id before releasing the app.

9
votes

"It could be that you have only recently created a new Ad Unit ID and requesting for live ads. It could take a few hours for ads to start getting served if that is that case."

I faced the same problem, if you can show test ads, it's fine, live ads will be showed soon (of course after you removed .addTestDevice(...) ).

I guess that google need time to collect some information (location, age, gender...) to show properly ads that can interest user.

May be you know but NEVER forget: DO NOT touch the live ads, you will be banned soon.

https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/fBe3YL3ffpo

6
votes

If you have removed:

.addTestDevice()

Then, make sure you are using the same ID that AdMob gave you in your string.xml file

AdMob ID page

5
votes

Answering an old question, but I had faced this same issue that test ads are visible and production key's Ads are not working.

I figured out later that I didn't gave my payment details to Admob.

Payment details in Admob are a must. Please update and check after few hours it starts appearing.

4
votes

Below is the official answer for time required to pass in order to display live ads.

How long does it take for ads to begin appearing after the first ad request?

When apps are newly registered with AdMob, it typically takes up to an hour and a few ad requests to allow inventory to build. Because of this, you may not see live impressions immediately.

Note: In some cases, it may take longer than an hour. Please wait 24 hours before seeking additional help.

Once your app is making more requests, you should see more consistent results. Please note that test ads operate through the same channels as live ads. Being able to return a test ad ensures that your application is communicating properly with our network.

Source: https://support.google.com/admob/answer/2993019?hl=en

4
votes

You have to add your payment information first. I forgot to do this in Google Admob so it wasn't showing any ads.

Also, make sure you use real Ad ID instead of the test ids.

3
votes

Look at your logcat. It will say why real ads are not being shown.

It's probably because there are none available to show for your device, in your location, right now.

3
votes

To create a Live Ad unit id

Sign In to

https://apps.admob.com

  1. in the left side menu click on ->Apps
  2. add app
  3. choose whether you have published your app on Google Play or the App Store
  4. if no -> Enter your app information
  5. Create Ad unit
  6. replace the test Ad unit with the new Ad unit.
  7. you get to see the AD once the app is published to playstore!

inside your xml add AdView

  <com.google.android.gms.ads.AdView 
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_ad_unit_id">
  </com.google.android.gms.ads.AdView>

inside Strings <string name="banner_ad_unit_id">your_new_ad_unit</string>

in your java code

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

I also was faced with this problem. AdView and IntersitialAd showed me only test advertisements on the simulator. But there were real advertisements on the real device. I think that firebase can detect if you use the simulator or the real device. I've used firebase:

com.google.firebase:firebase-ads:11.0.4

0
votes

If you chose the Native Express template then use this link. NativeExpressAdView won't work with AdView. https://firebase.google.com/docs/admob/android/native-express

NativeExpressAdView adView = (NativeExpressAdView)findViewById(R.id.adView);

<com.google.android.gms.ads.NativeExpressAdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ads:adUnitId="ca-app-123123123123/123123123"
    ads:adSize="320x150">
</com.google.android.gms.ads.NativeExpressAdView>
0
votes

Actually, I also faced this problem. You have to log in to admob and go to the app you added there. That app has an admob id. Use the id of the app to do these steps. Then create a new banner or whatever type of ad in that app (in admob) and use the id of that banner to complete these steps. When you create a banner, it will give you the instructions itself.

0
votes

In my case, it was because of wrong keystore file path in app > build.gradle. Make sure you have correct storeFile file('file path')enter image description here

I am sure it will help someone find the answer.

0
votes

It probably is not showing Ad because your app is still in development mode, you can register a test device in your ad mob account by following the instructions here. You should be able to see the ads on a test device even in development mode.

Copying the steps here

  • Sign in to your AdMob account at https://apps.admob.com.
  • Click Settings in the sidebar.
  • Click the Test devices tab.
  • Click Add test device.
  • Select the platform of your device.
  • Enter a device name. Consider using a name that will help you quickly identify your devices in your AdMob account. Note: The device name will be visible to anyone who has access to your AdMob account.
  • Enter your Advertising ID/IDFA. Learn how to find your advertising ID/IDFA.
  • Select a gesture to use to activate ad inspector: None, Shake OR Flick twice
  • Click Done.