Android广告XML属性缺失

时间:2015-11-26 21:19:21

标签: android ads

当我运行我的应用时,我的横幅上出现错误XML attribute adSize was missing。我的XML代码:

<com.google.android.gms.ads.AdView
    xmlns:ads="http://schemes.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitID="@string/banner_ad_unit_id"/>

我的onCreate代码:

AdView mAdView = (AdView) findViewById(R.id.adView);
    mAdView.setAdSize(AdSize.SMART_BANNER);
    mAdView.setAdUnitId("AD_ID");

    AdRequest adRequest = new AdRequest.Builder().addTestDevice(Secure.getString(this.getContentResolver(), ANDROID_ID)).build();
    mAdView.loadAd(adRequest);

1 个答案:

答案 0 :(得分:0)

更改

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

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

schem a s,而非schem e s