解析 XML 时出错:未绑定的前缀 Admob



我的布局中遇到了问题,我试图添加Admob。

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads ="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/lined2"
tools:context=".MainActivity" >
    <com.google.ads.AdView
    android:id ="@+id/adview"
    android:layout_width="fillparent"
    android:layout_height="wrap_content"
    ads:adUnitId="My ID"
    ad:adSize="BANNER"
    ads:testdevices="TEST_EMULATOR"
    ads:loadAdOnCreate="true" />

所以错误在这一行:

 <com.google.ads.AdView

它说:

Error parsing XML:unbound prefix 

真的搜索了很多帖子,但没有人帮助我......我准备好添加带有添加 xmlns:ads 的行....但这无济于事:/我忘了吗。?

感谢您的帮助!

您错过了命名空间中的s adSize

改变

ad:adSize="BANNER"

ads:adSize="BANNER"
<com.google.ads.AdView
android:id ="@+id/adview"
android:layout_width="fillparent"
android:layout_height="wrap_content"
ads:adUnitId="My ID"
**ads:adSize="BANNER"**
ads:testdevices="TEST_EMULATOR"
ads:loadAdOnCreate="true" />

校正。

最新更新