I’ve got my AdMob code implemented into my XML file like this:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="30dp"
android:layout_height="30dp"
ads:adUnitId="???????"
ads:adSize="BANNER"
ads:loadAdOnCreate="false"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
In my onCreate method of my activity:
// load ads
AdView adView = (AdView)findViewById(R.id.adView);
AdRequest request = new AdRequest();
//request.setTesting(true);
adView.setAdListener(new AdListener() {
public void onReceiveAd(Ad arg0) {
// TODO Auto-generated method stub
}
public void onPresentScreen(Ad arg0) {
// TODO Auto-generated method stub
}
public void onLeaveApplication(Ad arg0) {
// TODO Auto-generated method stub
}
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
// TODO Auto-generated method stub
}
public void onDismissScreen(Ad arg0) {
// TODO Auto-generated method stub
}
});
adView.loadAd(request);
I can put a break point in the onReceivedAd listener and always stop in there when I run my app; however, nothing displays. My AdMob page shows requests happening as well. I’ve tried in and out of test mode (see the commented out line above) with the same results.
Also, lest anyone ask, my ads:adUnitId=”????” is set to the Publisher ID found next to my app on the AdMob website.
Anyone got suggestions on how to debug this from here?
Remove
TabWidgetandFrameLayoutand try again just for testing.I think
android:layout_height="fill_parent"onFrameLayoutis the problem.