안드로이드 뷰에서 발생하는 빈번한 문제, XML 오류 파싱 : 결합되지 않은 접두사

StackOverflow https://stackoverflow.com/questions/2221221

문제

Android View에서 빈번한 문제가 있습니다. 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) 첫 번째 노드는 다음을 포함해야합니다.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"

다른 팁

여기에 보지 않기 때문에 별도의 답변을 추가 할 것입니다. Pentium10이 요청한 것은 100%가 아니지만 검색하여 여기서 끝났습니다. Error parsing XML: unbound prefix

Admob 광고와 같은 사용자 정의 매개 변수를 사용하고있는 것으로 나타났습니다. ads:adSize, 그러나 나는 추가하지 않았다

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

레이아웃에. 일단 추가하면 훌륭하게 작동했습니다.

나는이 같은 문제가 있었다.

접두사 (Android : [무엇이든)가 올바르게 철자를 작성하고 올바르게 작성되었는지 확인하십시오. 라인의 경우 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"

오류 메시지는 시작하는 모든 것을 참조하고 있습니다. "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>

안드로이드 컴파일러는 아직 정의되지 않았기 때문에 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"

이것은 나를 위해 트릭을했다.

저에게는 첫 번째 줄에서 "Unbound Prefix"오류를 얻었지만 네 번째 줄에서 Android가 잘못되었습니다.

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

나는 같은 문제가 있었고 솔루션은 Android : 도구를 첫 번째 노드에 추가하는 것임을 발견했습니다. 제 경우에는 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 파일에 사용되는 모든 네임 스페이스에 대한 네임 스페이스가 필요하다는 것입니다.

번역 : Blah가 네임 스페이스이고 Fubar가 XML 태그 인 네임 스페이스가있는 태그가있는 XML 태그 이름입니다. 네임 스페이스를 사용하면 다양한 도구를 사용하여 자체 태그 이름으로 XML을 해석 할 수 있습니다. 예를 들어 Intel XDK는 네임 스페이스 IntelxDK를 사용하고 Android는 Android를 사용합니다. 따라서 다음과 같은 네임 스페이스가 필요하거나 빌드가 혈액을 버려야합니다 (예 : XML : Unbound Prefix) : 네임 스페이스를 사용했지만 정의하지 않았습니다.

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

이 오류는 일반적으로 포함하지 않은 경우 발생합니다. xmlns:mm 적절하게, 그것은 일반적으로 첫 번째 코드 줄에서 발생합니다.

나에게 그것은 ..

xmlns : mm = "http://millennydedia.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" >

좋아, 여기에는 많은 솔루션이 있지만 실제로 문제의 근본 원인을 설명하지 않으므로 여기서 간다.

당신이 같은 속성을 볼 때 android:layout_width="match_parent" 그만큼 android 부분은 접두사이고 여기에 속성의 형식은 다음과 같습니다. PREFIX:NAME="VALUE". XML에서 네임 스페이스와 접두사는 예를 들어 이름 지정 충돌을 피하는 방법입니다. a:a="val" 그리고 b:a="val".

접두사를 사용합니다 android 또는 app 또는 다른 사람은 네임 스페이스를 사용하여 정의해야합니다 xmlns 기인하다.

따라서이 문제가있는 경우 네임 스페이스가 정의되지 않은 접두사를 찾으십시오. tools:... 당신이 제안한대로 도구 네임 스페이스를 추가해야합니다. app:... 추가해야 할 속성 xmlns:app="http://schemas.android.com/apk/res-auto" 루트 요소에

추가 읽기 :

XML 네임 스페이스 간단한 설명

W3의 XML 네임 스페이스

제 경우에는 오류가 위의 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" />

이 모든 것 외에도이 오류가 발생하는 시나리오도 있습니다.

귀하 또는 귀하의 라이브러리 프로젝트가 Custom Attribute Int Attr.xml을 정의하고 네임 스페이스를 정의하지 않고 레이아웃 파일에서 이러한 속성을 사용합니다.

일반적으로 우리는 레이아웃 파일의 헤더 에서이 네임 스페이스 정의를 사용합니다.

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

그런 다음 파일의 모든 속성이 Shoud를 시작하는지 확인하십시오.

android:ATTRIBUTE-NAME

Attirbute 중 일부가 Android 이외의 다른 것으로 시작하지 않으면 Identfy가 필요합니다 : Attribute-Name

temp:ATTRIBUTE-NAME

이 경우이 "온도"는 일반적으로 포함하여 네임 스페이스로도 있습니다.

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

루트 태그에 적절한 이름 공간을 추가하면됩니다. xmlns : android = "http://schemas.android.com/apk/res/android"Android elemets는이 이름 공간에서 선언되어 클래스 또는 패키지 가져 오기와 동일합니다.

일반적으로 안드로이드를 잘못 놓으면 나에게 일어난다 - 나는 단지 안드로리드를 입력하거나 비슷하게 입력한다. 태그 - 만약 그렇다면 면밀한 모습이 있고 오타가 어디에 있는지 알 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top