Unexpected namespace prefix "xmlns" found for tag LinearLayout

エラーエラー

エラーメッセージ

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


概要


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


原因


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


対策


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

実際に遭遇したエラー例

 閲覧数:840 投稿日: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 を変数に解決できません



週間人気ページランキング / 8-28 → 9-3
順位 ページタイトル抜粋 アクセス数
1 Android FAQ 8
2 キーバインドの競合が発生しました。 通常のアクセラレーター操作を妨げる可能性があります。 | エラー(エラー) 4
3 この行に複数マーカーがあります | エラー(エラー) 3
4 実際に遭遇した例 2
4 ○○は解決できないか、フィールドではありません | エラー(エラー) 2
4 プラグイン "org.eclipse.ui.workbench" からのコードの起動で問題が発生しました | エラー(エラー) 2
5 パターン2 … 「android:layout_weight」を使用(1-4-3-5)しているのに、「android:layout_width」を"0dp"にしていない 1
5 遭遇例 / 解決した方法 1
5 パターン2 … 「android:layout_weight」を使用(1-2-3)しているのに、「android:layout_width」を"0dp"にしていない 1
5 ★★ を型に解決できません | エラー(エラー) 1
5 複数画面が存在する時、起動後初期表示される画面はどこで決まるの? | 仕組み 1
5 プラグイン "org.eclipse.ui.workbench" からのコードの起動で問題が発生しました 1
5 手順 1
5 Eclipseが起動しない … ユーザ操作は待機中です | Eclipse(IDE) 1
5 2.作成したアクティビティクラスを追加 1
5 基本的な処理の流れ 1
5 エラー対応 1
5 複数パッケージ対応例 1
5 XMLファイルを「配置」する方法 1
5 実際に遭遇した例2 1
2026/9/4 5:05 更新