Required xml attribute adsize was missing in android studio

When adding the adView widget to an Android App in Android Studio, you might initially get the error:  “Required xml attribute adsize was missing in android studio” displayed in red on your widget in the design view.

Adding the following line to your activity_main.xml could help solve this problem.

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