Resource id not found for attribute 'id' and 'order in category' in package 'android'

I am getting this error in the menu.xml file. this is odd since i have checked my code many times. I tried clearing and renaming the id but had no effect and also tried to build the project but the project didn’t build due to this error, can someone help me with this. I have already tried different questions but couldn't find an answer. here is my code I also tried the solutions given in this question but didn't use: Resource id not found for attribute 'showAsAction' in package 'android'

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res-auto">
<item
    android:id="@+id/action_add_new_alarm"     //error is here.
    android:icon="@drawable/action_bar_add"
    android:orderInCategory="100"
    android:showAsAction="ifRoom"        //error is here
    android:title="" />

<!--&lt;!&ndash;&ndash;&gt;-->
</menu>

      

and the error i am getting is this

Error:(3) No resource identifier found for attribute 'id' in package 'com.xxx.xxxxx'
Error:(3) No resource identifier found for attribute 'orderInCategory' in package '

      

And one more thing that I use in android studio.

+3


source to share


2 answers


You should change "android: showAsAction to" app: showAsAction as shown below:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"> //Then you can use this
    <!-- Search, should appear as action button -->
    <item android:title="@string/action_search"
        android:id="@+id/action_search"
        android:icon="@drawable/ic_action_search"
        app:showAsAction="ifRoom"/>   //change android: to app:

    <!-- Settings, should always be in the overflow -->
    <item android:id="@+id/action_settings"
        android:title="@string/action_settings"
        app:showAsAction="never" />   //change android: to app:
</menu>

      



This worked for me

+7


source


change

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

      

to



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

      

it should work.

+2


source







All Articles