My activity_main.xml layout file indicates an error: error parsing XML: unbound prefix. No idea why - it seems related to the AdView.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<-- ERROR HERE - error parsing XML: unbound prefix -->
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="ca-app-pub-xxxxxx/xxxxxx"
ads:adSize="SMART_BANNER"/>
</LinearLayout>
You forgot to define the ads prefix for the custom attributes (adSize & adUnitId).
Add to the LinearLayout container:
xmlns:ads="http://schemas.android.com/apk/res-auto"
More details here.
You may have forgotten to add this
xmlns:ads="http://schemas.android.com/apk/res-auto"
Have you also included the right library?
Related
I would like to implement the color picker library at https://github.com/attenzione/android-ColorPickerPreference:
To setup, in a dialog, the xml is added according to the instruction in website, and is as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" >
<RelativeLayout
android:id="#+id/message_dialog"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/layout_round_corners_blue" >
<net.margaritov.preference.colorpicker.ColorPickerPreference // error line
android:layout_width="wrap_content"
android:layout_height="wrap_content"
holo:defaultValue="#color/pumpkin_orange"
holo:key="color1"
holo:summary="#string/color1_summary"
holo:title="#string/color1_title" />
</RelativeLayout>
</RelativeLayout>
Question:
The xml reports error error: Error parsing XML: unbound prefix at the above error line marked.
What is the problem for the above xml?
you have to change this <net.margaritov.preference.colorpicker.ColorPickerPreference to your package where you add this class like
<com.example.yourPackagewhereyouAddThisClass.ColorPickerPreference
like
net.margaritov.preference.colorpicker
change this above to your package Name where you add you ColorPickerPreference Class
Problem Appeared : When i have open my XML file and changing the layout_height attribut.
Problem description : Suspicious namespace: should start with http://
Line problem* :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:pj="http://schemas.android.com/apk/res/com.example"
xmlns:bm="com.example" <!-- problem line -->
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:background="#drawable/basic"
android:orientation="vertical" >
If you need a custom namespace, use the Android auto-namespace feature.
In your example:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" />
Clean your project and if the problem persist restart your IDE
Hi im just started programming and i just get this error message
"Multiple annotations found at this line:
- The markup in the document following the root element must be well-
formed."
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/jcea"
/>
</LinearLayout>
You're closing the LinearLayout element twice. Remove one of the closing tags, e.g.:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/jcea"
/>
Replace the /> with a >, or remove the /.
In xml, /> is another way of closing a tag if it does not have any data associated with it. For example, the following two statements are both valid and identical:
<tag></tag>
and
<tag/>
That being said, you should change your code snippet to either:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/jcea">
</LinearLayout>
or
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/jcea"/>
Trying to make some changes in XML file and new problem fired up:
Her's code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
xmlns:map="http://schemas.android.com/apk/res/android"
map:id="#+id/map"
map:name="com.google.android.gms.maps.MapFragment"
map:layout_width="wrap_content"
map:layout_height="250dp" />
</LinearLayout>
Got error at
xmlns:map="http://schemas.android.com/apk/res/android"
Unexpected namespace prefix "xmlns" for tag fragment
Not sure if I'm helpful here but i only declare the Namespace once in my case in the RelativeLayout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment class="com.blablabla.MyFragment"
android:id="#+id/fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
I dont declare the namespace again in the fragment as shown above. As far as I know the Namespace only has te be declared once in the parent ViewGroup
If I had to guess, you are most likely running into this bug in the build tools.
I'm using adMob sdk 4.3.1 for android and am using xml to create the layout as explained here using Eclipse IDE. The problem is that eclipse doesn't recognize the com.google.ads.AdView tag and gives the error error: error parsing XML: unbound prefix. How do I fix this?
EDIT-Here's the code for the layout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="MY_AD_UNIT_ID"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR,e78b974e6ab65648b52951e69edcb571"
ads:loadAdOnCreate="true"/>
</LinearLayout>
Just add xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" to the layout!
I'm just guessing here, you'll have to post your xml (obviously):
You're missing xmlns:android="http://schemas.android.com/apk/res/android" or you've spelt something wrong.