Skip to content Skip to sidebar Skip to footer

Required Xml Attribute "adsize" Was Missing

I get a 'Required XML attribute 'adSize' was missing' when I launch my app. This is written on the screen of my smartphone instead of my banner. I tried the different solutions f

Solution 1:

Try changing your declaration this way:

<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"/>

---- EDIT ----

You can also try to do it programmatically. Simply, instead of an AdView layout item, define a LinearLayout and by code do something like this:

finalAdViewadView=newAdView(getActivity());
adView.setAdUnitId("YourId");
adView.setAdSize(AdSize.BANNER);

finalLinearLayoutadLinLay= (LinearLayout) view.findViewById(R.id.your_defined_linearlayout);
adLinLay.addView(adView);

final AdRequest.BuilderadReq=newAdRequest.Builder();
finalAdRequestadRequest= adReq.build();
adView.loadAd(adRequest);

Solution 2:

Here is a weird answer. I just restarted my eclipse and it stared working. This might help some one.

Just restart eclipse, android studio or IntelliJ IDE

Solution 3:

I have same problem.

Solution for me:

 xmlns:ads=""

changed to

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

Solution 4:

Problem fixed for me by changing name space uri

from

 xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

to

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

Solution 5:

I had the same problem and I corrected it with the xmlns labels. I put two "xmlns:ads" labels (one for "res-auto" in the AdView and other for "tools" in the parent layout). I had to use two labels for "res auto", one with xmlns:app in the FloatingActionButton and other with xmlns:ads in the AdView:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.v7.widget.Toolbar
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/fragment_start_margin"
        android:background="@drawable/fondo_proyectos"
        android:elevation="4dp"
        android:gravity="bottom"
        android:minHeight="@dimen/toolbar_height">
    </android.support.v7.widget.Toolbar>

    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/av_bottom_banner"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_inferior_ad_unit_id"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        />

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/av_bottom_banner"
        android:fitsSystemWindows="true">

        <android.support.design.widget.FloatingActionButton
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/av_bottom_banner"
            android:layout_alignParentEnd="true"
            android:layout_gravity="bottom|end"
            android:layout_marginLeft="@dimen/fab_margin"
            android:layout_marginRight="@dimen/fab_margin"
            android:elevation="4dp"
            android:src="@android:drawable/ic_input_add"
            android:tint="@android:color/white"
            app:fabSize="normal"
            app:srcCompat="@drawable/ic_account_circle" />

        <include layout="@layout/proyecto_content" />

    </android.support.design.widget.CoordinatorLayout>

</RelativeLayout>

Post a Comment for "Required Xml Attribute "adsize" Was Missing"