Unexpected namespace prefix “xmlns” found for tag LinearLayout

前端 未结 7 850
离开以前
离开以前 2020-11-30 05:36

I am having an error in following xml file. \"Unexpected namespace prefix \"xmlns\" found for tag LinearLayout\". I tried the solutions provided in other similar qu

相关标签:
7条回答
  • 2020-11-30 05:49
    xmlns:android="http://schemas.android.com/apk/res/android
    

    remove the above tag

    and keep

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

    or </fragment>

    0 讨论(0)
  • 2020-11-30 05:51

    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.

    0 讨论(0)
  • 2020-11-30 05:53

    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.

    0 讨论(0)
  • 2020-11-30 05:56

    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.

    0 讨论(0)
  • 2020-11-30 06:04

    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.

    0 讨论(0)
  • 2020-11-30 06:09

    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.

    0 讨论(0)
提交回复
热议问题