I have frequent error in android xml file in menu folder. XML parsing error: unbound prefix

I have this error in the menu_main.xml file in the menu folder:

error:Error parsing XML unbound prefix.

      

my code

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

<item
    android:id="@+id/action_settings"
    android:title="@string/action_settings"
    android:orderInCategory="100"
    app:showAsAction="never"/>

<item
    android:id="@+id/menu_search"
    android:title="@string/menu_search"
    appcompat:showAsAction="always"/>

      

+3


source to share


4 answers


<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
    android:id="@+id/action_settings"
    android:title="@string/action_settings"
    android:orderInCategory="100"
    android:showAsAction="never"/>

<item
    android:id="@+id/menu_search"
    android:title="@string/menu_search"
    android:showAsAction="always"/>

</menu>

      



+1


source


Unbound prefix. You have to look android:

, app:

and appcompat:

.

This line



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

      

defines a namespace android

("ns" from "xmlns"). app

and appcompat

should be defined the same way.

+3


source


<menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools">

    <item
      android:id="@+id/action_settings"
      android:title="@string/action_settings"
      android:orderInCategory="100"
      app:showAsAction="never"/>

    <item
      android:id="@+id/menu_search"
      android:title="@string/menu_search"
      app:showAsAction="collapseActionView|always"
      app:actionViewClass="android.support.v7.widget.SearchView/>

</menu>

      

+1


source


please check below solutions.

You see this error with wrong namespace or typo in attribute. Like "xmlns" it should be xmlns: android

otherwise put the complete xml code.

0


source







All Articles