Android 意外的命名空间前缀";xmlns";为标记线性布局找到
我在下面的xml文件中出错。为标记LinearLayout找到意外的命名空间前缀“xmlns”。我也尝试了其他类似问题中提供的解决方案,但对我来说不起作用。在使用Android 意外的命名空间前缀";xmlns";为标记线性布局找到,android,xml,eclipse,android-xml,Android,Xml,Eclipse,Android Xml,我在下面的xml文件中出错。为标记LinearLayout找到意外的命名空间前缀“xmlns”。我也尝试了其他类似问题中提供的解决方案,但对我来说不起作用。在使用LinearLayout的3行中出现相同错误 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="f
LinearLayout
的3行中出现相同错误
<?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>
请尝试以下操作:
删除
xmlns:android=”http://schemas.android.com/apk/res/android
除了滚动视图
之外的所有位置。我相信只要在xml文件的最外层布局或视图中通知应用程序一次就足够了。我在各种代码中多次遇到这个问题
这些代码在过去运行得非常好,但现在它们显示了这些错误
我发现了一个非常简单的解决方案,不需要任何代码更改(添加、编辑或删除)
转到选项卡上的“项目”选项卡
单击选项卡
从列表中选择“清洁…”
您将看到在工作空间中打开的所有项目的列表
您可以选择一个项目,也可以选择所有项目(我通常会“清理所有项目”)。
单击“确定”。
这一过程大约需要5-7秒才能完成10个项目。
所有XMLNS错误都已解决。。。
在尝试任何其他解决方案之前,您应该先尝试此解决方案。。。。
这就像重新启动Windows错误的系统,解决了70%的问题
上述解决方案更像是一种适用于所有情况的临时解决方案。。
为了避免将来出现这种情况,我将所有xmlns代码放在顶部。(可能需要删除重复的语句)
在XML文件上集成Admob时,我遇到了这个问题。对于突然看到这条消息出现的人来说,
Sudhir
的评论应该是可以接受的答案。Sudhir
的英语不是很好,我想:如果你遇到困难:在eclipse中转到project
菜单单击clean…
并选择clean all项目
这将删除此消息作为消息的随机外观。在Android xml文件中,该消息在之前丢失的情况下,Android命名空间可以:
- 只能申报一次
- 只能在xml层次结构的顶部('outer')Android
视图中声明
滚动视图
,因此请保留
xmlns:android="http://schemas.android.com/apk/res/android"
在滚动视图中
,并将其从所有其他嵌套的视图
中删除,包括线性布局
xmlns:android="http://schemas.android.com/apk/res/android
移除上面的标签
保持
<fragment
..........
........
........
......../>
或者
我认为删除不需要的行更合适,因为:
1) 清理项目只会解决一次问题。如果再次启动项目或从另一个文件切换到此xml文件,它将再次显示错误
2) 更重要的是,“
xmlns:XXX
”应该是第一个节点的属性。要使此问题一劳永逸地消失,而不会对源进行大量更改(这会给版本跟踪带来噪音),请执行以下操作:
转到“问题”选项卡--右键单击消息--选择“快速修复”。
此时会出现一个窗口,您可以告诉Eclipse在项目中忽略此问题(如果愿意,也可以在一个文件中忽略)
在那之后,XML将可以编译。这很奇怪(而且不一致)语法分析器应该拒绝重复的名称空间声明。这是哪个XML语法分析器?先生,如何查看正在使用哪个语法分析器?我一直在使用Eclipse ADT bundle附带的默认语法分析器。谢谢,将xmlns行保留在主线性布局中,并将其从其余嵌套布局中删除是可行的。这绝对是第一件应该尝试的事情。很多时候清理项目是可行的,其他一些解决方案也提出了同样的建议。但是,即使在那之后,删除该行对我也不起作用。如果您甚至不想等待项目清理时间,请在eclispe中打开Problems视图,选择来自xml命名空间的错误并删除它们(按Canc或在上下文菜单中选择Delete)。有趣的eclipse,不是吗?大家好,上面的解决方案与我不匹配,但这个解决方案非常完美,而且运行良好……非常感谢@Sudhir。。在我的情况下@Shobhit的答案是正确的。Sudhir建议进行全面清理/重建,尽管有效,但对大多数用户来说太明显了。我同意@DavidManpearl,Sudhir的answer是一个解决方案,Shobhit是一个永久解决方案