Zak*_*ley 2 admob google-play-services android-studio
我正在尝试使用 Admob 在我的应用中投放广告。
但是,它一直说“缺少必需的 XML 属性“adSize””,即使该属性在我的 XML 文件中。
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="MY UNIT ID"
ads:adSize="BANNER"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会这样?
干杯。
确保您的布局具有,xmlns:ads="http://schemas.android.com/apk/res-auto"属性,以及为什么使用layout_widthasfill_parent而不是wrap_content,因此也尝试更改它。
如果您还没有,请查看本教程。主要有activity_main.xml
您的整个 XML 布局文件也将有助于找出问题所在。您可以删除不想发布的内容
或者,尝试从这个答案中将您的声明更改为以下内容:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="YOUR_AD_UNIT_ID"
ads:adSize="BANNER"/>
Run Code Online (Sandbox Code Playgroud)
人们还建议重新启动您的 IDE
| 归档时间: |
|
| 查看次数: |
3844 次 |
| 最近记录: |