为什么在android中显示错误意外的名称空间前缀xmlns?

时间:2013-07-22 20:11:11

标签: android xml

我想在我的应用中展示Google广告,但在此代码unexpected namespace prefix xmlns上显示错误xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"。如果我删除此行,则会显示Error parsing XML:unbound prefix。请帮我确定哪里出了问题。这是我的代码。

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/background_port"
    tools:context=".MainActivity">

    <LinearLayout xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:gravity="center"
              >

    <com.google.ads.AdView android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         ads:adUnitId="a151b801b7c1d6b"
                         ads:adSize="BANNER"
                         ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
                         ads:loadAdOnCreate="true"/>
    </LinearLayout>

    --------------------
    ---- More views ----
    --------------------

 </LinearLayout>

1 个答案:

答案 0 :(得分:10)

通过清理项目删除错误

项目菜单 - &gt;清洁 - &gt;选择Proj - &gt;行

相关问题