Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No resource identifier found for attribute 'id' and 'order in category' in package 'android'

I am getting this error in my menu.xml file. this is odd since I have checked my code many times. I have tried cleaning and renaming the the id but no effect and also tried to build the project but project didn't build due to this error can anybody help me with this. I have tried different questions already but didn't found the answer. here is my code I have also tried the solutions given in this question but no use: No resource identifier 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 I am using android studio.

like image 929
Umair Avatar asked Dec 04 '25 13:12

Umair


1 Answers

You should change "android:showAsAction to "app:showAsAction as per 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

like image 131
0110100110 Avatar answered Dec 07 '25 03:12

0110100110



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!