Unexpected namespace prefix "xmlns" found for tag LinearLayout

エラーエラー

エラーメッセージ

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


概要


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


原因


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


対策


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

実際に遭遇したエラー例

 閲覧数:836 投稿日: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-7 → 8-13
順位 ページタイトル抜粋 アクセス数
1 Android FAQ 16
2 public 型 ★★ はそれ独自のファイル内に定義されなければなりません | エラー 3
3 この行に複数マーカーがあります | エラー(エラー) 2
3 「Live Template」で「fbc」が表示されない | Android Studio(IDE) 2
3 「SQLite dumpデータ」を出力しても無意味 2
4 Eclipseが自動的に必要なパッケージを判断して、インポート(自動記述) | Eclipse(IDE) 1
4 ○○は解決できないか、フィールドではありません | エラー(エラー) 1
4 クラス(環境構築) カテゴリー 1
4 please select Android SDK | Android Studio(IDE) 1
4 「Android Studio 3.0.1」でプロジェクトを選択するためには? 最初に「現在開いているプロジェクト」を閉じる必要がある | Android Studio(IDE) 1
4 実際に遭遇した例 1
4 PCのエミュレータ上で動かしているAndroidアプリで、ローカルファイルを保存したとき、何処に保存されているの? 1
4 This text field does not specify an inputType or a hint | 警告(エラー) 1
4 「SQLite Database 」へ保存したデータを確認したい | SQLite 1
4 Gradle(環境構築) カテゴリー 1
4 E/Trace(★★): error opening trace file: No such file or directory | エラー(エラー) 1
4 キーバインドの競合が発生しました。 通常のアクセラレーター操作を妨げる可能性があります。 | エラー(エラー) 1
4 Unexpected error while launching logcat | エラー(エラー) 1
4 メソッド onCreate(Bundle) は型 Object で未定義です | エラー 1
4 Your project contains error(s),please fix them before running your application | エラー(エラー) 1
2026/8/14 5:05 更新