Reputation: 6882
I have successfully made my admob ads show up on the sample code provided by Google at http://code.google.com/mobile/ads/docs/android/fundamentals.html, but when it comes to my own app, they do not show up.
I've read some related questions but it doesn't seem to be an issue for the LinearLayout which I am using. One thing to notice is that in my app it extends ListActivity instead of Activity.
<?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/com.mypackage.myapp"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2">
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
ads:adUnitId="myadmobid"
ads:adSize="BANNER"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2">
<TextView
android:id="@+id/hottopictab"
android:text="Deal"
android:gravity="center_horizontal|center_vertical"
android:background="#000000"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textStyle="bold"
android:typeface ="sans"
android:layout_weight="1"/>
<TextView
android:id="@+id/newtopictab"
android:text="()"
android:gravity="center_horizontal|center_vertical"
android:background="#000000"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textStyle="bold"
android:typeface ="sans"
android:layout_weight="1"/>
<TextView
android:id="@+id/recommendtab"
android:text=""
android:gravity="center_horizontal"
android:background="#000000"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<ImageButton
android:layout_height="fill_parent"
android:id="@+id/refresh"
android:background="#000000"
android:src="@drawable/refresh"
android:layout_width="wrap_content"
android:layout_marginRight="6dip"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="40">
<ListView
android:id="@android:id/list"
android:text="row one"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
Upvotes: 0
Views: 6219
Reputation: 14556
just waiting 30 minutes worked for me. I restarted the app, and the add showed up.
Upvotes: 0
Reputation: 6882
Problem solved. It was due to not enough space "Not enough space to show ad! Wants: <480, 75>, Has: <336, 522>". When I enlarge my emulator, it works.
Upvotes: 2
Reputation: 4207
I had this problem when I implemented Admob a few hours ago.
What I did was went into my admob account and set the application to supply 'in house ads' for unfilled inventory.
I then set up a fake in-house ad (which im going to latter make a ad to buy the non ad version of the app).
What this means is if you request a ad from admob from your app and there is currently no demand, your in house ad will be shown instead.
Hope this helps
Upvotes: 0
Reputation: 1973
Check your logCat when you are on the activity / method that should populate your ad. I had a problem where it wouldn't show because the banners require 50dip vertical space, and I was only giving it 50px (not the same thing). LogCat will give you a warning saying it couldnt fit in requested space.
Also, are you calling
AdView adView = (AdView)this.findViewById(R.id.adView);
adView.loadAd(new AdRequest());
in your activity somewhere? You must request an ad, they dont load automatically.
And another thing, putting ads in your layout, you need to make sure you have an attrs.xml file like the adMob tutorial shows.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="com.google.ads.AdView">
<attr name="adSize">
<enum value="1" name="BANNER"/>
<enum name="IAB_MRECT" value="2"/>
<enum name="IAB_BANNER" value="3"/>
<enum name="IAB_LEADERBOARD" value="4"/>
</attr>
<attr format="string" name="adUnitId"/>
</declare-styleable>
</resources>
Upvotes: 4
Reputation: 10948
Set admob to be a test account. Then you will be able to see if it is an Admob issue or an issue with your code.
Also, check Logcat - it may be the case that there just aren't any ads available for you at this time.
Upvotes: 1