Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Admob ads not showing - Android

My ads don't display at all, I think I've followed the documentation correctly but they still won't show. The program is basically a webview and I want the ad to display at the bottom.

Heres my layout file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
   <WebView
      android:id="@+id/webview"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" />
   <com.admob.android.ads.AdView
      android:id="@+id/ad"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      myapp:backgroundColor="#000000"
      myapp:primaryTextColor="#FFFFFF"
      myapp:secondaryTextColor="#CCCCCC" />
</LinearLayout>

Any ideas?

EDIT: this is what I now have but it still doesn't appear to be quite right:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >
<com.admob.android.ads.AdView 
    android:id="@+id/ad"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    myapp:backgroundColor="#000000"
    myapp:primaryTextColor="#FFFFFF"
    myapp:secondaryTextColor="#CCCCCC" />
<WebView
    android:id="@+id/webview"
    android:layout_above="@id/ad"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
</RelativeLayout>
like image 541
user319940 Avatar asked Sep 01 '10 08:09

user319940


People also ask

How long does it take for AdMob to show ads?

Ad serving 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.

Why is my AdMob not working?

some common issues are : Make sure you have updated AdMob with your payment details. Make sure that the ads you created in AdMob are banner ads. Check your AdMob dashboard to see the status of your ads, are they active?

Why are ads not working on my phone?

MOBILE ADS TROUBLESHOOTINGEnsure you don't have too many apps running in the background. Check to see if there are any privacy settings/settings on your device that restrict you from viewing ads. Check that your Internet provider/region does not restrict ads, or your modem/provider doesn't throttle ads or ad content.

How do I know if AdMob ad is working?

Test devicesWhen you enable a test device, the AdMob Network sends production ads in test mode to your device using the ad unit IDs you've created in your AdMob account. This lets you safely test production ads and verify your implementation code without violating AdMob's invalid traffic policy.


2 Answers

Your Problem is that the WebView will take all the space on the screen and there is no space left for the ads.

A LinearLayout will distribute the space on a first come first serve rule. If the first View takes all the space the second view won't get any space..

I would use a RelativeLayout and add the adds first with a layout_alignParentBottom attribute and then add the webview with a layout_above="id for the adds". This will ensure that the adds are always on the bottom of the screen even if the webview wont take all the space at the moment and the webview will always be above the adds.

like image 162
Janusz Avatar answered Sep 20 '22 08:09

Janusz


I had the same problem, i fixed it this way: LinearLayout as main layout, inside it linearLayout(for the ad) and a webview, set wrap_content on the linearlayout for the ad, so, it will first show an ad and then the rest of the screen will be the webview. example of mine:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
  <LinearLayout 
 android:id="@+id/addmob"
 xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
></LinearLayout>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>



</LinearLayout>
like image 32
Diego Avatar answered Sep 21 '22 08:09

Diego