64

I am attempting to update my android application to look better for tablets running Honeycomb. As such, I am targeting version 11 of the SDK (my minSdkVersion = 4). This adds the Honeycomb theme to my app, making it look better. However, I have no way to access my menu options. So, I am attempting to add my menu items as an action bar item with the following in the file in my /res/menu/ folder:

android:showAsAction="ifRoom|withText"

However, I get the following error:

No resource identifier found for attribute 'showAsAction' in package 'android'

I tried altering my minSdkVersion number to 11 to see if it would work, but no luck. Any ideas? Thanks!

Community
  • 1
  • 1
ariets
  • 4,218
  • 4
  • 28
  • 34
  • I immediately thought it was because showAsAction was added in API level 11, but you've taken that into consideration it seems. – Codemonkey Mar 10 '11 at 14:20
  • That's what I had thought, which is why I added it. But, since I am developing in Eclipse, I needed to change my entire project target to #11, as Jason suggested below. – ariets Mar 10 '11 at 16:30
  • I got this error when I changed my project target to version 8. It turns out `showAsAction` was mentioned in the XML files when the target was higher, so I simply removed that line from the XMLs that gave the error and it solved the issue. – Superbest Oct 30 '12 at 21:48

9 Answers9

65

If you are building with Eclipse, make sure your project's build target is set to Honeycomb too.

Jason Hanley
  • 3,225
  • 2
  • 24
  • 21
34

remove android:showAsAction="never" from res/menu folder from every xml file.

Narendra Pathai
  • 41,187
  • 18
  • 82
  • 120
Saurabh
  • 7,525
  • 4
  • 45
  • 46
  • 4
    Why should that be necessary? android:showAsAction="never" can actually come in handy sometimes. – IgorGanapolsky Jan 03 '14 at 18:00
  • 2
    Although this wasn't the desired action, it was the best temporary solution. I imported the android-support-v7-appcompat.jar, but it wasn't loading properly until I removed the android:showAsAction="never" lines from my XMLs, deleted the gen folder, cleaned the project, and rebuilt. After I had a build without errors, I could add the android:showAsAction="never" back into my XMLs without errors. – MrUser Oct 07 '14 at 22:40
22

all above fix may not work in android studio .if you are using ANDROID STUDIO...... use this fix

add

xmlns:compat="http://schemas.android.com/tools"

in menu tag instead of

xmlns:compat="http://schemas.android.com/apk/res-auto"

in menu tag.

petey
  • 16,914
  • 6
  • 65
  • 97
kumar kundan
  • 2,027
  • 1
  • 27
  • 41
16

Add "android-support-v7-appcompat.jar" to Android Private Libraries

user3192555
  • 169
  • 1
  • 3
15

Add compat library compilation to the build.gradle file:

compile 'com.android.support:appcompat-v7:19.+'
eleven
  • 6,779
  • 2
  • 32
  • 52
5

The problem is related to AppCompat library. With it, you have

xmlns:appname="http://schemas.android.com/apk/res-auto"

and possibly:

appname:showAsAction="never"

in menu.xml file.

Without the lib, you can only have:

android:showAsAction="never"

and my app works with menu both on Android 4.3 and 2.3.3.

Yar
  • 4,543
  • 2
  • 35
  • 42
0

Check your compileSdkVersion on app build.gradle. Set it to 21:

compileSdkVersion 21
Renato Probst
  • 5,914
  • 2
  • 42
  • 45
0

go to gradle and then to app.buildgradle then set compileSDKVersion to 21 and then if necessary the android studio will download some files

sagar
  • 1
0

From answer that was removed due to being written in Spanish:

All of the above fixes may not work in android studio. If you are using ANDROID STUDIO please use the following fix.

Use

xmlns: compat = "http://schemas.android.com/tools"

on the menu label instead of

xmlns: compat = "http://schemas.android.com/apk/res-auto"
Souleste
  • 1,887
  • 1
  • 12
  • 39