0
我的AdMob塊中的應用程序的佈局等NativeExpressAdView adSize時SMART_BANNER
<android.support.constraint.ConstraintLayout ...>
...
<com.google.android.gms.ads.NativeExpressAdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
app:adSize="350x100"
app:adUnitId="ca-app-pub-..."
app:layout_constraintTop_toBottomOf="@+id/refresh"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
在主活動還有的AdMob initializeaion代碼:
MobileAds.initialize(this, "ca-app-pub-...");
NativeExpressAdView adView = (NativeExpressAdView) findViewById(R.id.ad);
// adView.setAdSize(AdSize.SMART_BANNER);
// adView.setAdUnitId("ca-app-pub-...");
AdRequest request = new AdRequest.Builder()
.addTestDevice(...)
.build();
adView.loadAd(request);
如果在佈局XML我設置app:adSize="350x100"
廣告塊被示出爲。 但是,當我嘗試設置app:adSize="SMART_BANNER"
,廣告塊遺漏,並有錯誤消息日誌:
收到的錯誤HTTP響應代碼:403
如果我刪除「程序:adSize時」和「應用程序:adUnitId設置」從XML和在活動設置編程,在取消上述
...
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId("ca-app-pub-...");
..
廣告塊中的代碼行中示出蒙山內部錯誤消息:
必需的XML屬性 「adSize時」 失蹤了。
如何將廣告尺寸設置爲SMART_BANNER
值?