3

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

galath
  • 5,717
  • 10
  • 29
  • 41
  • `app:showAsAction` and `appcompat:showAsAction`should be `android:showAsAction` – Bunny Jul 17 '15 at 06:13
  • possible duplicate of [frequent problem in android view, Error parsing XML: unbound prefix](http://stackoverflow.com/questions/2221221/frequent-problem-in-android-view-error-parsing-xml-unbound-prefix) – galath Jul 17 '15 at 06:26
  • Also a duplicate of [this one](http://stackoverflow.com/questions/6329295/error-parsing-xml-unbound-prefix) – galath Jul 17 '15 at 06:27

4 Answers4

3

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.

galath
  • 5,717
  • 10
  • 29
  • 41
3
<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>
beresfordt
  • 5,088
  • 10
  • 35
  • 43
Aman Jham
  • 478
  • 6
  • 18
1
<?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>
Sohail Zahid
  • 8,099
  • 2
  • 25
  • 41
0

please check the below solutions.

You see this error with an incorrect namespace, or a typo in the attribute. Like 'xmlns' is wrong, it should be xmlns:android

otherwise put full xml code.