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

时间:2014-02-13 12:01:48

标签: java android 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 ....的行,但它没有帮助:/ 我忘记了吗?

感谢您的帮助!

2 个答案:

答案 0 :(得分:1)

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

更改

ad:adSize="BANNER"

ads:adSize="BANNER"

答案 1 :(得分:1)

<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" />

校正。