Android ビューで頻繁に発生する問題、XML 解析エラー:アンバウンドプレフィックス
-
19-09-2019 - |
質問
Androidビューで頻繁に問題が発生します。 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"
LinearLayout
を使用している場合は、4)あなたはツールを定義する必要があります:
xmlns:tools="http://schemas.android.com/tools"
他のヒント
私はここでそれを見ていないという理由だけで、別の答えを追加するつもりです。それはPentium10のために尋ね、100%ではないのですが、私はError parsing XML: unbound prefix
を検索することによって、ここで終わった。
私は
ads:adSize
などのAdMob広告のカスタムパラメータを使用していたが判明したが、私は追加していませんでした
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タグ名持って何とかは、名前空間で、めちゃくちゃは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:mm="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で、名前空間接頭辞とは、私たちのような2つの同じ名前の明確な属性が異なるプレフィックス持つことができ、たとえば競合命名避けるための方法があります:。a:a="val"
とb:a="val"
は
あなたはandroid
属性を使用して名前空間を定義する必要がありapp
またはxmlns
またはその他のような接頭辞を使用します。
あなたがこの問題を持っている場合だけで、名前空間が定義されていない接頭辞を見つけるように、あなたには、いくつかのansweresが示唆したようにあなたは、ツールの名前空間を追加する必要がありますtools:...
している場合、あなたはルート要素にapp:...
を追加する必要があります属性xmlns:app="http://schemas.android.com/apk/res-auto"
を持っている場合は、
さらに読みます:
私の場合はエラーが上記の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"
次に、ファイル内のすべての属性で始まるshoudを確認してください。
android:ATTRIBUTE-NAME
のように属性名:あなたのattirbuteの一部は、Android以外の何かを起動していない場合は、あなたはidentfyする必要があります
temp:ATTRIBUTE-NAME
この場合、あなたは一般的に含むことによって、名前空間としても、この「TEMP」を持っている -
xmlns:temp="http://schemas.android.com/apk/res-auto"
あなたは自分のルートタグに適切な名前空間を追加する必要があります。 xmlns:アンドロイド= "http://schemas.android.com/apk/res/android" Androidのelemetsは、クラスまたはパッケージをインポートすると同じ、この名前space.Itsで宣言されています。
私はアンドロイドのスペルを間違えたときには、通常、私に起こります検索は、1個のタグをスキップする - それは、私は近い顔をしているんやタイプミスがあった場所、私が見た場合、
。