我在机器人视图常见的问题,Error parsing XML: unbound prefix on Line 2

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:id="@+id/myScrollLayout" 
android:layout_width="fill_parent"  android:layout_height="wrap_content">
    <TextView android:layout_height="wrap_content" android:layout_width="fill_parent" 
    android:text="Family" android:id="@+id/Family" 
    android:textSize="16px" android:padding="5px" 
    android:textStyle="bold" android:gravity="center_horizontal">
    </TextView>

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:orientation="vertical" android:scrollbars="vertical">
        <LinearLayout android:orientation="vertical" android:id="@+id/myMainLayout" 
        android:layout_width="fill_parent"  android:layout_height="wrap_content">
        </LinearLayout>
    </ScrollView>

</LinearLayout>
有帮助吗?

解决方案

一个几个原因,这可能发生在:

1)你看到此错误使用不正确的命名空间,或在属性一个错字。像 '的xmlns' 是错误的,但是应当xmlns:android

2)第1节点需要包含: xmlns:android="http://schemas.android.com/apk/res/android"

3)如果要集成的AdMob,检查等ads:adSize自定义参数,则需要

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

4)如果你正在使用LinearLayout您可能需要定义工具:

xmlns:tools="http://schemas.android.com/tools"

其他提示

我要添加一个单独的答案,只是因为我没有看到它在这里。这不是100%是什么Pentium10要求,但我在这里结束了通过搜索Error parsing XML: unbound prefix

原来我使用AdMob广告等ads:adSize自定义参数,但是我没有添加

    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

要的布局。有一次,我加入它是伟大的工作。

我有这个相同的问题。

确认该前缀(机器人:[任何])拼写正确,并且正确写入。在线路xmlns:android="http://schemas.android.com/apk/res/android"的情况下 请确保您有充分的前缀xmlns:android和拼写正确。同样的,任何其他前缀 - 确保拼写正确,并有android:[name]。这是解决我的问题。

至于你提到,你需要指定正确的命名空间。你也看到这个错误与不正确的命名空间。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:padding="10dip">

将不起作用。

  

变化:

xmlns="http://schemas.android.com/apk/res/android"
  

xmlns:android="http://schemas.android.com/apk/res/android"
  

在错误消息所指的一切,开始“机器人:”作为XML不知道“android:”命名空间是什么

。      

xmlns:android定义它。

可以此错误的情况下发生您使用的未定义的前缀,例如:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TabHost
    XYZ:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >


</TabHost>

Android的编译器不知道是什么,因为它是没有定义XYZ。

在你的情况下,应该添加以下定义为根的XML文件的节点。

xmlns:android="http://schemas.android.com/apk/res/android"

  

未结合的前缀错误的 ViewPager指示器:

随着在parentLayout下面的头标记:

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"

另外补充:

xmlns:app="http://schemas.android.com/apk/res-auto"

这奏效了我。

对于我来说,我就在这里第一行中的“绑定前缀”的错误,虽然我曾在第四行拼错的机器人。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
anrdoid:fillViewport="true"
>

我有同样的问题,并发现该溶液是向机器人添加:工具到第一节点。在我的情况下,它是一个LineraLayout:

    <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="vertical">

我会扔在多为新手和乡亲,像我,不理解XML一点。

以上一个很好的答案,但最普遍的回答是,你需要在config.xml文件中使用的任何命名空间的命名空间。

翻译:有任何XML标签名称是用一个命名空间,其中嗒嗒是命名空间和FUBAR是XML标签的标签。命名空间可以让你使用许多不同的工具,用自己的标签名称解释XML。例如,英特尔XDK使用命名空间intelxdk和Android采用了Android。因此,你需要下面的命名空间或构建抛出了血(即错误解析XML:未绑定的前缀),它被翻译成:你使用的命名空间,但并未定义它。

  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:intelxdk="http://xdk.intel.com/ns/v1"

通常如果尚未包括在xmlns:mm正确发生此错误,它在第一行代码通常发生。

对我来说是..

<强>的xmlns:毫米= “http://millennialmedia.com/android/schema”

,我错过了在代码的第一行

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mm="http://millennialmedia.com/android/schema"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="50dp"
android:layout_marginBottom="50dp"
android:background="@android:color/transparent" >

OK,这里有很多的解决方案,但实际上非所以在这里我们去解释这个问题的根本原因:

当你看到这样的android:layout_width="match_parent"属性android部分是前缀,在此属性的格式是PREFIX:NAME="VALUE"。在XML中,命名空间和前缀办法避免命名例如我们可以有具有相同名称的两个不同的属性,但像不同的前缀冲突:a:a="val"b:a="val"

要使用像androidapp或任何其他前缀您应该使用xmlns属性定义名称空间。

所以,如果你有这样的问题,只是觉得没有一个命名空间中定义,前缀如果你已经tools:...你应该添加工具命名为一些answeres建议,如果你有app:...属性,你应该添加xmlns:app="http://schemas.android.com/apk/res-auto"根元素

进一步阅读:

XML命名空间简单的解释

XML命名空间在W3

在我的情况下不被任何上述的XML命名空间的问题而引起的误差。相反,它是android:id属性的位置 - 它需要在特定元素的声明中的第一项。

因此,这:

<TextView android:layout_width="fill_parent" 
      android:layout_height="wrap_content"
      android:id="@+id/bottomtext" 
      android:singleLine="true" />

...需要读这样的:

<TextView android:id="@+id/bottomtext" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"
      android:singleLine="true" />

除了这一切,也存在其中该错误occures的场景 -

当您或您的库项目定义自定义属性INT attr.xml,而你使用你的布局文件这些属性没有定义命名空间。

一般我们用这个命名空间定义在我们的布局文件的标题。

xmlns:android="http://schemas.android.com/apk/res/android"

然后请确保您的文件中的所有属性与768,16启动

android:ATTRIBUTE-NAME

您需要identfy如果你的一些attirbute的不与比Android以外的东西开始:属性的名称,如

temp:ATTRIBUTE-NAME

在这种情况下,你有这样的“温度”也作为命名空间,通常通过包括 -

xmlns:temp="http://schemas.android.com/apk/res-auto"

您只需要在你的根标记添加适当的命名空间。 的xmlns:机器人= “http://schemas.android.com/apk/res/android” 的Android elemets在此名称space.Its相同导入类或包中声明。

它通常发生在我身上时,我拼错的Android - 我只需键入的Andorid或相似,而且特别多小时的节目之后是一见钟情不明显,所以我只是做了搜索“Android”的一个,看看一个搜索跳过一个标签 - 如果是的话那么我有一个近距离观察,我看到了错字

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top