error: Error parsing XML: unbound prefix in admob - android

I tried many combination but it showing following error in xml file
error: Error parsing XML: unbound prefix
in <com.google.ads.AdView line, how can i resolve this.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<com.google.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
myapp:adUnitId="000000000000000"
myapp:adSize="BANNER"
myapp:refreshInterval="30"
/>
</RelativeLayout>
<ListView
android:id="#+id/list_of_wishes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="2dip"
android:clickable="true" >
</ListView>
</LinearLayout>

I'd like to think that you should be using the ads: instead of myapp:, but I might be wrong. Let me know if this doesn't work for you:
<com.google.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="000000000000000"
ads:adSize="BANNER"
ads:refreshInterval="30"
/>
The reason for this possibly helping would be the fact that you've set an ads namespace, but not myapp (as seen in this line):
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

Related

Admob ad showing error in xml

I am stuck in a problem and search alot but could'nt find the solution here is my code
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
app:adSize="BANNER"
app:adUnitId="xxxxxxxxxx" >
</com.google.ads.AdView>
This code show
Error parsing XML:unbound prefix
when i remove app:adUnitId and app:adsize it do not give any error, how can i remove this error?
Your error is typographical, you're setting:
app:adSize="BANNER"
app:adUnitId="xxxxxxxxxx"
But it should be:
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxx"
xmlns:ads="http://schemas.android.com/apk/res-auto"
Add this to your parent tag.
In my case.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:orientation="vertical" >
Hope this will work.

Layout Adview - Error Parsing XML Unbound Prefix

My code is:
//Error parsing XML: unbound prefix error
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
andorid:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId=""
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
/>
<WebView
android:id="#+id/webkit"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
What is wrong? I don't know.
I try change "xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" to "android:ads="http://schemas.android.com/apk/lib/com.google.ads", but it can't solve
Try this..
android spelling wrong in your andorid:layout_height change it and try it.
android:layout_height="wrap_content"
change andorid:layout_height to android:layout_height="wrap_content"
take reference from below layout example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:background="#000000"
android:orientation="vertical" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="AD_UNIT_ID"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR"
/>
<FrameLayout
android:id="#+id/rootFrameLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>

android layout overlay issue

I am a beginner in android.I made a flash game android app using a webview and integrated admob ad banner but it is overlaying the webview.I need it to appear like this pic http://i46.tinypic.com/2cosrjp.png
this is my code :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="#+id/lay"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<WebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="a1513fab869115a"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
</RelativeLayout>
add android:layout_below="+id/lay" inside you webView view
<RelativeLayout
android:id="#+id/lay"
android:layout_below="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<WebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
add android:layout_alignParentTop="true" in ads view
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="a1513fab869115a"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
Even though RelativeLayout might be the first choice for many use cases, for this simple view I would use a LinearLayout, that's much easier.
i got the oppiste error, i want my app displayed as yours and i cant get it, i got the answer that u want.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1">
<com.google.android.gms.ads.AdView android:id="#+id/adView"
android:layout_width="355dp"
android:layout_height="wrap_content"
ads:adUnitId="000000000000000000"
ads:adSize="BANNER"
android:layout_gravity="center_horizontal|bottom" />
<WebView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="#+id/tropas"
android:layout_weight="1.01" />
</LinearLayout>
this is my code and display Aadmob on top Not overlaying webview

"No resource found" When using <include layout="">

In my project I have created a global header layout global_header.xml and I use it in all of my layout XML files by using <include layout="#layout/global_header.xml">.
I have used this method before, and I am currently using it in this project. My problem is that I have a layout with the following contents:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFFFF" >
<include layout="#layout/global_header" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/global_header">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Contents of global_header.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/global_header"
android:layout_width="fill_parent"
android:layout_height="60sp"
android:layout_alignParentTop="true"
android:background="#FFDDDDDD" >
<ImageView
android:id="#+id/global_header_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5sp"
android:layout_marginTop="5sp"
android:adjustViewBounds="true"
android:src="#drawable/header" />
<View
android:layout_width="fill_parent"
android:layout_height="1sp"
android:layout_alignParentBottom="true"
android:background="#FF000000" />
</RelativeLayout>
And I am getting an error on android:layout_below="#global/header" saying that:
error: Error: No resource found that matches the given name (at 'layout_below' with value '#global/header').
I have used the include in other layouts in the project and it works without a problem, but for whatever reason, this layout file will not load the ID from the header where as all other layouts do.
The project will not build with this error even though I am sure that once running on the device it will find it not a problem, has anyone else had this problem? Is there solution/workaround?
Any and all help is greatly appreciated.
Try this, specify id for include layout and use
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFFFF" >
<include layout="#layout/global_header" android:id="#+id/header"/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/header">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</RelativeLayout>
</ScrollView>
Hope both xml (main.xml & global_header.xml) is exist in your layout folder within resources.
kindly clean the project and restart your eclipse, it works.
Note# I checked your xmls I didn't got any error.

AdMob in android "AdView missing required XML attribute 'adSize' "

I am trying to implement AdMob in my Application. But dont know somehow its showing this error and my R.java file is not being generated due to it. I have tried all the ways to solve this problem, like Clean,Build, Build All. But non is working for me.
Following my code snippet in which its showing error "Error in parsing XML: Unbound prefix"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
android:background="#color/bgcolor">
<LinearLayout
android:id="#+id/Linearlayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="XXX"
ads:refreshInterval="60"/>
</LinearLayout>
Please help me out. I am stuck here :(
Probably a namespace issue. You have to define the namespace.
try adding
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
New Admob SDK (Google Play services) requiried another namespace
xmlns:ads="http://schemas.android.com/apk/res-auto"
<?xml version="1.0" encoding="utf-8"?>
<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:id="#+id/rltvLayoutPromote"
android:layout_height="fill_parent">
<LinearLayout android:id="#+id/linearLayoutwebview"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical">
<WebView android:id="#+id/webViewPromote"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:fitsSystemWindows="true" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:id="#+id/ad_layout" android:layout_height="wrap_content"
android:gravity="bottom" android:layout_alignParentBottom="true"
android:layout_alignBottom="#+id/home_layout">
<com.google.ads.AdView android:layout_width="wrap_content"
android:layout_height="wrap_content" ads:adUnitId="XXXXXXXXXX"
ads:adSize="BANNER" android:id="#+id/adView" ads:refreshInterval="60" />
<!-- put 3 if not working-->
</LinearLayout>
</RelativeLayout>
and put this lines in manifest.xml file
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />
the above code is working perfectly for me... visit this site for complete reference help forandroid-admobThanks Pragna

Categories

Resources