Admob ads not showing

I am trying to implement Admob in Android, and I see requests coming to AdMob. However, I do not see Admob ads displayed on the Android screen in the emulator and on my Android test phones.

As stated above, I see requests coming to my AdMob account. However, the content is not displayed. Is there anything that needs to be included in my account, main.xml, AndroidManifest.xml or in the application download?

My configuration and application code are given below. Please tell us 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"/> 

home:

  <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"/> 

In the Create code field:

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

Any help is appreciated!

+8
source share
12 answers

Make sure that the layout in which AdView is embedded does not impose any additions to AdView. AdView size should be exactly 320x50. It does not appear if it does not have enough space.

Also check the log output on your device. In Eclipse, switch to the DDMS perspective, select your device and see the output of LogCat.

+11
source

I had a similar problem. If you have padding on the parent layout, you may not have enough width for the ads. If you have a portrait view, try switching to a landscape to see if it shows. If this is the case, you probably have a width problem somewhere in your layout.

+8
source

Usually, ads start appearing through admob. This happens when you just registered with admob and started from the first application. If the above suggestions are taken care of, and if your admob page shows a “green” status, I won’t worry too much about that. As soon as your bid is filled, you will begin to see more and more ads.

+5
source

Make sure your Admob layout is displayed as XML. Put your look at admob in RelativeLayout and try using android:alignparentBottom:true

  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <!--Do our code that you want to show in xml --> <!--Put adview in bottom of screen --> <com.google.ads.AdView android:id="@+id/adView" android:layout_width="fill_parent" android:layout_height="wrap_content" ads:adSize="BANNER" android:layout_alignParentBottom="true" ads:adUnitId="@string/addmob_id" ads:loadAdOnCreate="true" ads:testDevices="HT9CWP803129" /> </RelativeLayout> </LinearLayout> 

In your Java code, put these lines in the onCreate method

 // Load addvertisment AdView adView = (AdView) findViewById(R.id.adView); // Request for Ads AdRequest adRequest = new AdRequest.Builder().addTestDevice("FF9CD441FA62FD456D7D571B91DD11DD").build(); adView.loadAd(adRequest); 

It worked in my code, hope this helps you too.

+4
source

Be careful with the identifier, there are 2 codes: the editor number (for example: pub-xxxxxxxxxxxxxxxx) and the other is the banner identifier (for example: ca-app-pub-xxxxxxxxxxxxxxxx / xxxxxxxxxx)

You need to use the latter, if you use the first, it does not work :)

+3
source

You are using ads: adUnitId = "My publisher ID" replace it with ads: adUnitId = "Here is the AdUnitId for this application" Note. You need to create an application on Admob, and you will get AdUnitId for this created application. You do not need to use the publisher ID.

+3
source

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

  1. The <metadata> section should contain ADMOB_APP_ID instead of your publisher ID. This should be declared in <application> 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 in the ADMOB toolbar, click on the application
    and check the "Application Settings". You can see the APP_ID that starts
    usually with ca-app-pub-0123456789012345.

  2. The second problem is where you declared AdView in your layout. Remember that you must provide the ad unit, not the publisher ID, which you can create in the ADMOB control panel by clicking on the ad unit tab.
    according to your statement. Place the correct “ad unit” in the AdView as shown below.

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

After resolving the above issues, follow these steps:

MobileAds.initialize(this, "YOUR_ADMOB_APP_ID"); to create your first activity. This needs to be done only once, and thus the right place is either your first action or the onCreate application callback.

Find the AdView in the onCreate action, where you included the 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"); 

In addition, if you want to handle promotional events, do the following: -

 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. } }); 
+3
source

Some of these possible solutions may seem obvious, but make sure they are implemented:

-replace "My publisher ID" in android: value = "My publisher ID" with your actual publisher ID.

- Be sure to include the Internet resolution in the manifest file:

  <uses-permission android:name="android.permission.INTERNET" /> 

If you have completed them, you can also try to place the following code in the "Under construction" section instead of the current one:

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

or

  AdManager.setTestDevices( new String[] {AdManager.TEST_EMULATOR}); AdView adView = (AdView)findViewById(R.id.adView); adView.requestFreshAd(); 

Before posting, don't forget to get rid of setTestDevice, though!

+2
source

make sure your publisher id admob is correct. This happened to me once, and I could not understand the error for about 15 days.

In Admob, each application you submit receives a different publisher ID. It is unique to each application, and not to the user.

+2
source

This may be a space problem, you need to make sure that the ad space will be displayed. If you have padding on the parent layout, this can reduce the available space. According to Google Admob docs, an ad will not be displayed if it does not display a space.

"The SDK will request any size requested by the requesting AdView. If there is not enough space on the device screen to display an ad, nothing will be shown."

So my suggestion is to ensure that there is no indentation on the parent layout and actually assign height and width to an ad banner like this

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

And save the appropriate sizes in a file of a dimension.xml in the values ​​folder.

+2
source

Go to app settings on admob.com and make sure that the use of location data for ads is disabled if your application is not a location-based application.

Use location data for ads is used to filter ads by location and only works in the app with permission. If the application does not use location permissions, ads will not be displayed.

+1
source

This is because an administrator’s inventory requires the generation of some queries to ensure that the application can bring some profit!

Please give the correct settings for advertising and publish the application, after about 1 thousand requests are completed, the advertisement will automatically appear!

I also suffered from this problem and got the answer when I published my own application!

0
source

All Articles