Unexpected namespace prefix “xmlns” found for tag LinearLayout

倾然丶 夕夏残阳落幕 提交于 2019-11-27 04:09:54

Please try following:

Remove xmlns:android="http://schemas.android.com/apk/res/android from all the places excluding the ScrollView. I believe it is sufficient to inform it to the application once and in the outermost Layout or View of the xml file.

I encountered this problem multiple times with various codes.

The codes were running absolutely fine in the past but now they are showing these errors....

I found a very simple solution, doesn't require any code changes (Addition, edit or deletion).

Go to the Project Tab at the tab Click on the tab Select the "Clean...." from the list

You will see the list of all the projects opened in your work space.

You can either select one project or all (I generally do "Clean all projects"). Click Ok. The process takes around 5-7 sec for around 10 projects. All the XMLNS errors are resolved... You should try this before trying any other solution.... This is like restarting the system for Window's error which resolves problems 70% of the times...

The above solution is more of a temp solution working in all situation.. To avoid the situation in future, I all xmlns codes together at the top. (there may be a duplicate statement that may be required to be deleted)

I was having this issue when integrating Admob on the XML file.

In an Android xml file, the Android namespace can:

  • only be declared once
  • only be declared in the top ('outer') Android View in the xml hierarchy

or you'll receive an error when building the project. In your case, the top Android view is the ScrollView, so keep

xmlns:android="http://schemas.android.com/apk/res/android"

in the ScrollView, and remove it from all other nested Views, including the LinearLayout.

for people who suddenly see this message appear, the comment from Sudhir should be the accepted answer.. the English wasn't that good I thought : so if you struggle: in eclipse go to project menu click clean... and pick clean all projects this will remove the random appearance of this as a message in a situation where it was missing before

lilingmzai

I think remove the unneeded line is a more suitable way because:

1) Clean the Project will only resolve the problem once. And if you launch the project again or switch from another file to this xml file, it will show the error again.

2) More importantly, "xmlns:XXX" should be the property of the first node.

user3040657
xmlns:android="http://schemas.android.com/apk/res/android

remove the above tag

and keep

<fragment
..........
........
........
......../>

or </fragment>

To make this problem disappear once and forever without mass changes in the source (that would introduce noise to version tracking):

Go to the "Problems" tab -- right click on the message -- select "Quick fix". A window appears where you can tell Eclipse to ignore this problem in the project (or in just one file, if you wish).

After that, the XML will compile ok.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!