Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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

error:Error parsing XML unbound prefix.

my code is

<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"/>

like image 502
Shikha Garewal Avatar asked Nov 17 '25 18:11

Shikha Garewal


2 Answers

Unbound prefix. You should look at android:, app: and appcompat:.

This line

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

defines the namespace android (the "ns" of "xmlns"). app and appcompat need to be defined the same way.

like image 156
galath Avatar answered Nov 20 '25 10:11

galath


<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>
like image 43
Aman Jham Avatar answered Nov 20 '25 10:11

Aman Jham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!