Unexpected namespace prefix "xmlns" found for tag LinearLayout

エラー > エラー

エラーメッセージ

 状態:解決済  閲覧数:5,830  投稿日:2013-05-29  更新日:2013-05-29
Unexpected namespace prefix "xmlns" found for tag LinearLayout
直訳
・LinearLayoutタグに予期せぬプレフィクス名前空間"xmlns"が見つかった


概要


・パーサが重複する名前空間宣言を拒否している


原因


・名前空間宣言が重複しているため


対策


・名前空間宣言を重複しないようにすれば良い

実際に遭遇したエラー例

 閲覧数:847 投稿日:2013-05-29 更新日:2013-05-29

修正前


・「xmlns:android="http://schemas.android.com/apk/res/android"」が重複している
▼レイアウトXML(res/layout/activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical"
   android:paddingTop="10dp"
   android:background="#a0a0a0"
   >
       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:background="#a0a0a0">



修正後


・内側の「xmlns:android="http://schemas.android.com/apk/res/android"」を削除し重複回避
▼レイアウトXML(res/layout/activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical"
   android:paddingTop="10dp"
   android:background="#a0a0a0"
   >
       <LinearLayout
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:background="#a0a0a0">



この行に複数マーカーがあります

Context を変数に解決できません



週間人気ページランキング / 10-8 → 10-14
順位 ページタイトル抜粋 アクセス数
1 Android FAQ 18
2 アプリをビルドして実行する | アプリ化(環境構築) 2
3 対応 1
3 エラー対応 1
3 複数画面が存在する時、起動後初期表示される画面はどこで決まるの? | 仕組み 1
3 「Android Studio 3.0.1」でプロジェクトを選択するためには? 最初に「現在開いているプロジェクト」を閉じる必要がある | Android Studio(IDE) 1
3 新規プロジェクトを作成する方法 | プロジェクト(環境構築) 1
3 「Android Studio 3.0.1」で、デザインプレビュー画面が表示されない。「waiting build for finish」が終わらない | Android Studio(IDE) 1
3 public 型 ★★ はそれ独自のファイル内に定義されなければなりません | エラー 1
3 Androidエミュレータで、PCキーボード入力を有効にしたい | エミュレータ(環境構築) 1
3 アプリケーション起動時に表示されるアクティビティを変更 | 仕組み 1
3 ログイン 1
3 既存JAVAプロジェクトをKotlinへ変換 | Kotlin(環境構築) 1
3 「android compile with 」プルダウン内容が表示されないため、プロジェクト作成完了ボタンをクリックできない | プロジェクト(環境構築) 1
3 気が付いたこと 1
3 ActivityManager: 警告: Activity not started, its current task has been brought to the front | 警告(エラー) 1
3 Unexpected namespace prefix "xmlns" found for tag LinearLayout | エラー(エラー) 1
3 R.java was modified manually! Reverting to generated version! | エラー(エラー) 1
3 ○○は解決できないか、フィールドではありません | エラー(エラー) 1
3 Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties | エラー(エラー) 1
2026/10/15 5:05 更新