not enough space to show ad wants 480 75

I tried a lot of things to do, but nothing helps. My problem is that my admob ad is not displaying and LogCat is writing this:

03-19 12:30:56.140: E/Ads(790): Not enough space to show ad! Wants: <480, 75>, Has: <432, 690>
03-19 12:30:56.140: E/Ads(790): Not enough space to show ad! Wants: <480, 75>, Has: <432, 357>

May be the problem is with emulator, not code? Will be very greatful for any help My manifest.xml:

        <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.gosha.whymod.MainActiviti"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>

</manifest>

MainActivity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads= "http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActiviti" >

<Button
    android:id="@+id/knopka"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="142dp"
    android:gravity="center"
    android:onClick="onClick"
    android:text="Get answer now" />

<TextView
    android:id="@+id/texte"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="32dp"
    android:gravity="center"
    android:text="Why modern art is so strange?"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/knopka"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="ca-app-pub-1837185169360297/2930943167"
    ads:loadAdOnCreate="true"
    ads:testDevices="TEST_EMULATOR" />

Answers


Replace

<com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/knopka"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="ca-app-pub-1837185169360297/2930943167"
    ads:loadAdOnCreate="true"
    ads:testDevices="TEST_EMULATOR" />

with

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
      <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/knopka"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="ca-app-pub-1837185169360297/2930943167"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR" />
</ScrollView>

Remove the paddingLeft and paddingRight from your RelativeLayout. That is what is causing the reduced display area.

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"

You are testing on an HDPI device and AdView needs 480x75 px to display an advert. of BANNER size

In your XML layout file, the parent RelativeLayout (Seems like auto created) padding values to left and right. Which will produce an activity less width than the actual screen resolution. So the inlaying child AdView will only get lesser screen size than 480p

Try to put a parent FrameLayout with RelativeLayout and AdView as childs, so the AdView will appear as an overlay on RelativeLayout

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads= "http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActiviti" >

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

    <Button android:id="@+id/knopka"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="142dp"
        android:gravity="center"
        android:onClick="onClick"
        android:text="Get answer now" />

    <TextView android:id="@+id/texte"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="32dp"
        android:gravity="center"
        android:text="Why modern art is so strange?"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

<com.google.ads.AdView android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/knopka"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="ca-app-pub-1837185169360297/2930943167"
    ads:loadAdOnCreate="true"
    ads:testDevices="TEST_EMULATOR" />


Need Your Help

How to allocate memory for an arbitrary-sized array of fixed-length C strings

c arrays string

I am trying to allocate memory for an array of C strings. I can guarantee that the strings fit within MAX_STRING_LENGTH characters, but I don't know at compile time how many strings will be in the ...

KMDF build types

winapi 32bit-64bit kmdf

When building a kernel mode device driver (KMDF) on Windows with Visual Studio 2013, there are 32 bit and x64 bit build options. The question is this: When installing the device drivers on the ta...