簡體   English   中英

解析 xml 時出錯:來自 com.google.android.gms.ads.AdView 的未綁定前綴

[英]Error parsing xml: unbound prefix from com.google.android.gms.ads.AdView

<com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="**************"
        ads:adSize="BANNER"
        ads:loadOnCreate="true"
        android:id="@+id/adView"/>

我在這里有這個代碼,帶有 xmlns:ads,但仍然收到未綁定前綴的錯誤,並且需要 XML 屬性“adsize”丟失。

在您的情況下,添加了兩個 xmlns:ads 名稱空間。 刪除 xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads",它將起作用。

我使用以下 xmlns 也遇到了同樣的問題,我可以解決這個問題。

xmlns:ads="http://schemas.android.com/apk/res-auto"

整個廣告視圖的代碼如下。

    <com.google.android.gms.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/textView1"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-3940256099942544/6300978111"/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM