Reputation: 1152
I am having an error in following xml file. "Unexpected namespace prefix "xmlns" found for tag LinearLayout". I tried the solutions provided in other similar questions also but it didn't work for me. Same error is occurring in 3 lines where LinearLayout
is used.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/menu_top_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/name_version"
android:textColor="@color/black"
android:textSize="20sp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
<!-- A horizontal line -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="30px" >
</FrameLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/start_stop_button"
android:layout_width="74dp"
android:layout_height="74dp"
android:text="@string/start_server" />
<Button
android:id="@+id/instructions"
android:layout_width="120dp"
android:layout_height="74dp"
android:text="@string/instructions_label" />
<Button
android:id="@+id/setup"
android:layout_width="74dp"
android:layout_height="74dp"
android:text="@string/setup_label" />
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="30px" >
</FrameLayout>
<!-- A horizontal line -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="#666666" >
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="10px" >
</FrameLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="2" >
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="@string/server_status"
android:textColor="@color/black"
android:textSize="16sp" />
<!-- A small spacer between the columns -->
<FrameLayout
android:layout_width="3sp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/server_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/unknown"
android:textColor="@color/black"
android:textSize="16sp" />
</TableRow>
</TableLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="10px" >
</FrameLayout>
<!-- A horizontal line -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="#666666" >
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="10px" >
</FrameLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="2" >
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="@string/my_url_is"
android:textColor="@color/black"
android:textSize="16sp" />
<!-- A small spacer between the columns -->
<FrameLayout
android:layout_width="3sp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/ip_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_url_yet"
android:textColor="@color/black"
android:textSize="16sp" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="@string/wifi_status"
android:textColor="@color/black"
android:textSize="16sp" />
<!-- A small spacer between the columns -->
<FrameLayout
android:layout_width="3sp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/wifi_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/unknown"
android:textColor="@color/black"
android:textSize="16sp" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/last_error_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="@string/last_error"
android:textSize="16sp"
android:visibility="gone" />
<!-- A small spacer between the columns -->
<FrameLayout
android:layout_width="3sp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/last_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/unknown"
android:textColor="#ff0000"
android:textSize="16sp"
android:visibility="gone" />
</TableRow>
</TableLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="10px" >
</FrameLayout>
<!-- A horizontal line -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="#666666" >
</FrameLayout>
<!--
<TextView android:id="@+id/proxy_header"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/proxy_experimental"
android:textSize="16sp"
/>
-->
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="2" >
<TableRow>
<!--
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/proxy_status"
android:textSize="16sp"
android:gravity="left"
/>
-->
<!-- A small spacer between the columns -->
<FrameLayout
android:layout_width="3sp"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<!-- A small spacer between the columns -->
<FrameLayout
android:layout_width="3sp"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<!-- A small spacer between the columns -->
<FrameLayout
android:layout_width="3sp"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<!-- A small spacer between the columns -->
<FrameLayout
android:layout_width="3sp"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
<!-- A horizontal line -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#666666" >
</FrameLayout>
<!-- A horizontal line -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#666666" >
</FrameLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_log"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/server_log_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false" />
</LinearLayout>
<TextView
android:id="@+id/server_log"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#333333" />
<!-- A horizontal line -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#666666"
android:visibility="gone" >
</FrameLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/session_monitor"
android:textColor="#ffffff"
android:visibility="gone" />
<CheckBox
android:id="@+id/session_monitor_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:visibility="gone" />
</LinearLayout>
<TextView
android:id="@+id/session_monitor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#333333"
android:visibility="gone" />
<!-- A horizontal line -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#666666" >
</FrameLayout>
<!-- It's visually pleasing to have some empty space at the bottom -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="15dp" />
</LinearLayout>
</ScrollView>
Upvotes: 51
Views: 66627
Reputation: 641
I think remove the unneeded line is a more suitable way because:
1) Clean the Project will only resolve the problem once. And if you launch the project again or switch from another file to this xml file, it will show the error again.
2) More importantly, "xmlns:XXX
" should be the property of the first node.
Upvotes: 1
Reputation: 16832
To make this problem disappear once and forever without mass changes in the source (that would introduce noise to version tracking):
Go to the "Problems" tab -- right click on the message -- select "Quick fix". A window appears where you can tell Eclipse to ignore this problem in the project (or in just one file, if you wish).
After that, the XML will compile ok.
Upvotes: 0
Reputation: 1
xmlns:android="http://schemas.android.com/apk/res/android
remove the above tag
and keep
<fragment
..........
........
........
......../>
or </fragment>
Upvotes: 0
Reputation: 431
I encountered this problem multiple times with various codes.
The codes were running absolutely fine in the past but now they are showing these errors....
I found a very simple solution, doesn't require any code changes (Addition, edit or deletion).
Go to the Project Tab at the tab Click on the tab Select the "Clean...." from the list
You will see the list of all the projects opened in your work space.
You can either select one project or all (I generally do "Clean all projects"). Click Ok. The process takes around 5-7 sec for around 10 projects. All the XMLNS errors are resolved... You should try this before trying any other solution.... This is like restarting the system for Window's error which resolves problems 70% of the times...
The above solution is more of a temp solution working in all situation.. To avoid the situation in future, I all xmlns codes together at the top. (there may be a duplicate statement that may be required to be deleted)
I was having this issue when integrating Admob on the XML file.
Upvotes: 43
Reputation: 26007
Please try following:
Remove xmlns:android="http://schemas.android.com/apk/res/android
from all the places excluding the ScrollView
. I believe it is sufficient to inform it to the application once and in the outermost Layout or View of the xml file.
Upvotes: 84
Reputation: 28470
In an Android xml file, the Android namespace can:
View
in the xml hierarchyor you'll receive an error when building the project. In your case, the top Android view is the ScrollView
, so keep
xmlns:android="http://schemas.android.com/apk/res/android"
in the ScrollView
, and remove it from all other nested Views
, including the LinearLayout
.
Upvotes: 6
Reputation: 278
for people who suddenly see this message appear, the comment from Sudhir
should be the accepted answer.. the English wasn't that good I thought : so if you struggle: in eclipse go to project
menu click clean...
and pick clean all projects
this will remove the random appearance of this as a message in a situation where it was missing before
Upvotes: 4