2

I'm trying to put ads in my app using Admob.

However, it keeps saying "Required XML attribute "adSize" was missing" even though that attribute is in my XML file.

    <com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adUnitId="MY UNIT ID"
    ads:adSize="BANNER"
    android:layout_alignParentStart="true"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true" />

Does any one know why this is happening?

Cheers.

Ian Storm Taylor
  • 8,520
  • 12
  • 55
  • 72
Zak Woolley
  • 169
  • 2
  • 15

1 Answers1

6

Make sure your layout has, xmlns:ads="http://schemas.android.com/apk/res-auto" attribute, also why you have layout_width as fill_parent instead of wrap_content, so try changing that too.

Look at this tutorial if you havent already. Mainly there activity_main.xml

You entire XML layout file would help figuring out the problem too. You can remove the content you don't you want to post

OR, try changing your declaration to the following, from this answer:

<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="YOUR_AD_UNIT_ID"
ads:adSize="BANNER"/>

people have also suggested restarting your IDE

Community
  • 1
  • 1
Zaid Qureshi
  • 1,203
  • 1
  • 10
  • 15