Admob shows Test ads but not real ads
AndroidAdmobAndroid Problem Overview
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>
Android Solutions
Solution 1 - Android
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.
Solution 2 - Android
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?
Solution 3 - Android
You might be using the sample unit id:
If you use above then you will see test ads.
Make sure you change to your own unit id before releasing the app.
Solution 4 - Android
"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
Solution 5 - Android
If you have removed:
.addTestDevice()
Then, make sure you are using the same ID that AdMob gave you in your string.xml file
Solution 6 - Android
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.
Solution 7 - Android
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
Solution 8 - Android
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.
Solution 9 - Android
To create a Live Ad unit id
Sign In to
- in the left side menu click on ->Apps
- add app
- choose whether you have published your app on Google Play or the App Store
- if no -> Enter your app information
- Create Ad unit
- replace the test Ad unit with the new Ad unit.
- 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);
Solution 10 - Android
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.
Solution 11 - Android
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
Solution 12 - Android
In my case, it was because of wrong keystore file path in app > build.gradle. Make sure you have correct storeFile file('file path')
I am sure it will help someone find the answer.
Solution 13 - Android
I had the same problem and thought I would never be able to fix it.
Reason of the error: Admob is showing test ads because the ad loaded from admob does not fit in the container, mostly a linear layout because the ad loaded is bigger in width.
Fix: How I fixed was to create a banner ad of custom size of 320x50 and then load it.
I'm unable to post my code in the answer, but you can figure out your own from Jay Patel's answer to the following stackoverflow question.
https://stackoverflow.com/questions/22853745/how-to-set-adsize
Solution 14 - Android
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>
Solution 15 - Android
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.
Solution 16 - Android
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.
Solution 17 - Android
Generally, it is happening because of two reasons:
- You defined your device as test device.
- If you are using emulator android studio, you always see test ads.
> According to Google documentation, android emulators & ios simulators are automatically configured as test devices.
For more information check Google Web Site.