I am trying to include ads in my test app, when I run the app in an emulator or a device I get a banner add saying Required XML attribute “adSize” was missing .
I have set xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" in com.google.android.gms.ads.AdView tag.
Not sure how to resolve this issue.
More details : Android Studio AI-141.1989493
Code snippet :
AdView mAdView = (AdView) findViewById(R.id.adView); mAdView.setAdSize(AdSize.BANNER); mAdView.setAdUnitId("ca-app-pub-xxxxx/xxxxxx"); AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice("E58D5904AA50D88E2FD63A1D1EF97B34") .build(); mAdView.loadAd(adRequest); AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" /> Activity_main.xml
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/LinearLayout01"> <TableRow android:id="@+id/LinearLayout0"> <com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="ca-app-pub-xxxxx/xxxxxx" ads:loadAdOnCreate="true" ads:testDevices="TEST_EMULATOR, E58D5904AA50D88E2FD63A1D1EF97B34"> </com.google.android.gms.ads.AdView>