com.admob.android.ads.AdView unbound prefix?

Rene picture Rene · Feb 11, 2011 · Viewed 14.7k times · Source

I tried to include admob to an Android app in Eclipse. But I get an error in the layout.xml. Eclipse tells me that com.admot.android.ads.AdView is an unbound prefix. I have the admob library included in the build path, following the pdf instruction. But it still does not seem to find the AdView class. But why?

Here is the layout producing the error:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/renegrothmann.kalah"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    >

            <renegrothmann.kalah.GameView
                android:id="@+id/gameView" android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_margin="2px"
                />

            <com.admob.android.ads.AdView
                android:id="@+id/ad"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                myapp:backgroundColor="#000000"
                myapp:primaryTextColor="#FFFFFF"
                myapp:secondaryTextColor="#CCCCCC"
                />

</LinearLayout>

Answer

n4rzul picture n4rzul · Jun 9, 2011

I had the same error wit this layout

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/topLayout"
>           
    <!-- Ad Placeholder -->
    <com.google.ads.AdView      
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="a14df07c16f171a"
        ads:adSize="BANNER"
        ads:loadAdOnCreate="true"
    />

</RelativeLayout>

Then I made it:

<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"
    android:id="@+id/topLayout"
>           
    <!-- Ad Placeholder -->
    <com.google.ads.AdView      
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="a14df07c16f171a"
        ads:adSize="BANNER"
        ads:loadAdOnCreate="true"
    />

</RelativeLayout>

Notice the second xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" in my RelativeLayout in the second example?
In fact if you remove the android namespace declaration xmlns:android="http://schemas.android.com/apk/res/android" it will start moaning about all the android components too.