I am trying to use NativeExpressAdView but instead of the ad it shows
Required XML attribute 'adSize' was missing
in a black background, red-bordered box. I am adding adUnit and adSize to the adView programmatically like this
<com.google.android.gms.ads.NativeExpressAdView
android:id="@+id/nativeAdView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
Java Code:
nativeAd = (NativeExpressAdView) itemView.findViewById(R.id.nativeAdView);
int widthInDP = context.getResources().getConfiguration().screenWidthDp;
widthInDP -= context.getResources().getDimension(R.dimen.activity_horizontal_margin);
nativeAd.setAdUnitId(context.getString(R.string.dummy_ad_unit_id));
nativeAd.setAdSize(new AdSize(widthInDP, 100));
nativeAd.loadAd(adRequest);
and adRequest was initially declared as follows:
adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("DD8112531D2B704F33C3B0314744E92B")
.addTestDevice("62F4961171DF9F253BC3639F7B9A686B")
.build();
I followed the tutorial as explained in the official docs of Firebase AdMob. Why cannot I show ads in NativeExpressAdView while setting ad size dynamically?