Android XML Error parsing XML unbound prefix

12,984

You need to set layout configuration on the main tag (RelativeLayout) and to set the namespace of ads:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
>      
Share:
12,984
badmanthe5
Author by

badmanthe5

Updated on June 14, 2022

Comments

  • badmanthe5
    badmanthe5 almost 2 years

    I had 2 errors but i got one fixed. I still have the Error parsing XML unbound prefix error thou at the com.admob.android.ads wats wrong?

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout>
    <WebView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    />
    
    <com.admob.android.ads.AdView
      android:id="@+id/ad" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"
      xmlns:backgroundColor="#000000"
      xmlns:primaryTextColor="FFFFFF"
      xmlns:secondaryTextColor="#CCCCCC"
      android:layout_alignParentTop="true"
      ads:adUnitId="xxxxxxxxxxxx"
      ads:adSize="BANNER"
      ads:loadAdOnCreate="true"
      /> 
    </RelativeLayout>     
    
  • badmanthe5
    badmanthe5 over 11 years
    So i replaced <RelativeLayout> with <RelativeLayout xmlns:android="schemas.android.com/apk/res/android" xmlns:ads="schemas.android.com/apk/res/com.suit.AdmobTest" android:layout_width="fill_parent" android:layout_height="fill_parent" > and im still getting the same error. BTW how can i make the code look as nice as yours, not a mess like it is now?
  • badmanthe5
    badmanthe5 over 11 years
    at line <com.admob.and... i have error Multiple annotations found at this line: - error: No resource identifier found for attribute 'adUnitId' in package 'com.suit.AdmobTest' - error: No resource identifier found for attribute 'loadAdOnCreate' in package 'com.suit.AdmobTest'
  • onof
    onof over 11 years
    Sorry, the namespace should be: schemas.android.com/apk/lib/com.google.ads. I updated the answer
  • badmanthe5
    badmanthe5 over 11 years
    Thanks there are no errors anymore but the app crashes. Will try on my actual phone.