Unexpected namespace prefix "xmlns" found for tag LinearLayout

エラーエラー

エラーメッセージ

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


概要


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


原因


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


対策


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

実際に遭遇したエラー例

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