1

I attempted to display adds using code below. I got the error "AdView missing requied xml attribute adSize".

What is the problem?

main.xml:

 <?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.jms.AdmobExample"
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent" >

 <com.google.ads.AdView     
       android:id="@+id/adView"
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"
       ads:adSize="BANNER"
       ads:adUnitId="a14f1d807e488dd" />
</LinearLayout>

attr.xml:

  <?xml version="1.0" encoding="utf-8"?>
     <resources>
     <declare-styleable name="com.google.ads.AdView">
     <attr name="adSize">
     <enum name="BANNER" value="1"/>
     <enum name="IAB_MRECT" value="2"/>
     <enum name="IAB_BANNER" value="3"/>
     <enum name="IAB_LEADERBOARD" value="4"/>
  </attr>
  <attr name="adUnitId" format="string"/>
 </declare-styleable>
</resources>
Kheldar
  • 5,361
  • 3
  • 34
  • 63
user1089640
  • 115
  • 1
  • 3
  • 14

4 Answers4

3

use this

 <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" >

    <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample"
        android:id="@+id/add_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"            
        ns:adSize="BANNER"
        ns:adUnitId="a14f1d807e488dd" >
    </com.google.ads.AdView>

 </Linearlayout>
NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98
2

To make it work with Google Play services use:

xmlns:ads="http://schemas.android.com/apk/res-auto"

in your XML file.

Amir Alagic
  • 1,780
  • 1
  • 12
  • 10
0

You are missing this in the xml file:

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
easycheese
  • 5,859
  • 10
  • 53
  • 87
0

It seems your adsize attribute is not recognized.

I would say, either your namespace attribute is the problem (add it), either you should check if you called attr.xml "attrs.xml", as it is supposed to be.

Note that this says attrs.xml is not necessary with newer versions of AdMob.

Community
  • 1
  • 1
Kheldar
  • 5,361
  • 3
  • 34
  • 63
  • i already add adsize attribute.what ur saying rolldnums am not getting – user1089640 Feb 02 '12 at 05:57
  • Then you may need to add the namespace in the : xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample" . Check http://stackoverflow.com/questions/5613398/admob-missing-required-xml-attribute-adunitid since the error seem to happen in the same conditions. – Kheldar Feb 02 '12 at 08:32