2013-07-22 13 views
5

Tôi muốn hiển thị quảng cáo Google trong ứng dụng của mình nhưng nó hiển thị lỗi unexpected namespace prefix xmlns tại thẻ này xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads". Nếu tôi xóa dòng này thì nó sẽ hiển thị Error parsing XML:unbound prefix. Xin hãy giúp tôi để xác định rằng mọi thứ đi sai. Đây là mã của tôi.Tại sao hiển thị lỗi xmlns tiền tố không gian tên không mong muốn trong android?

<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> 
+0

Đôi khi lint trong AS là thực sự chính xác. Vấn đề của tôi là tôi đã cố gắng sử dụng https://github.com/TonicArtos/SuperSLiM và hóa ra các thẻ mà thư viện sử dụng chỉ được phép đặt trong chế độ xem gốc của tệp xml chứ không được đặt ở chế độ xem con. Tôi không phải đề cập đến điều đó khi tôi bỏ qua lint thư viện không hoạt động đúng cách. – vanomart

Trả lời

10

Các lỗi bị loại bỏ bằng cách làm sạch DỰ ÁN

menu Project -> Sạch -> Chọn Proj -> OK