9

I need to add the action bar for devices 2.3 and higher.

I recently knew about the appcompat v7 support library, which does exactly that.

I've followed the Support library setup guide, step by step, cleaned, built, and cleaned again, restarted eclipse, upgraded SDK and plugin to the last version (just to realise that SDK build tools v19 are broken, so I had to delete them). Two hours later I'm still unable to build my project. I'm getting these errors:

    [2013-11-13 00:00:00 - FooProject] D:\foo_project\android-support-v7-appcompat\res\values-v11\themes_base.xml:33: error: Error: No resource found that matches the given name: attr 'android:windowActionBar'.
    [2013-11-13 00:00:00 - FooProject] D:\foo_project\android-support-v7-appcompat\res\values-v11\themes_base.xml:42: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.
    [2013-11-13 00:00:00 - FooProject] D:\foo_project\android-support-v7-appcompat\res\values-v11\themes_base.xml:44: error: Error: No resource found that matches the given name: attr 'android:windowActionBar'.
    [2013-11-13 00:00:00 - FooProject] D:\foo_project\android-support-v7-appcompat\res\values-v14\themes_base.xml:31: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo'.
    [2013-11-13 00:00:00 - FooProject] D:\foo_project\android-support-v7-appcompat\res\values-v14\themes_base.xml:41: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.
    [2013-11-13 00:00:00 - FooProject] D:\foo_project\android-support-v7-appcompat\res\values-v14\themes_base.xml:57: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.
    [2013-11-13 00:00:00 - FooProject] D:\foo_project\android-support-v7-appcompat\res\values-v14\themes_base.xml:67: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.
    [2013-11-13 00:00:00 - FooProject] D:\foo_project\android-support-v7-appcompat\res\values-v14\themes_base.xml:83: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar'.
    [2013-11-13 00:00:00 - FooProject] D:\foo_project\android-support-v7-appcompat\res\values-v14\themes_base.xml:94: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.

And I've tried everything in the following questions, to no avail:
Adding Support Libraries to Android project
After setting up android-support-v7-appcompat R.java is missing
Android Support Library v7: Error retrieving parent for item
Can't Find Theme.AppCompat.Light for New Android ActionBar Support
How to resolve the error "No resource found that matches the given name" when adding library v7 AppCompat in Eclipse?

I'm not saying those answers are not valid, just that for some reason they didn't work for me (I think it's because Google hates me).

Here are my manifest lines for the target sdk:

For the library:

<uses-sdk android:minSdkVersion="7"/>

and for the main project:

<uses-sdk android:targetSdkVersion="19" android:minSdkVersion="8"/>

Tried every possible combination, cleaning and building after each change, and still no luck.

Looks like this is a problem related to Holo. I really don't need Holo at all, only ActionBar. For now I'm just switching to ActionBarSherlock, which worked well for me in the past. But I'd really like to know what am I doing wrong, why something does not work despite I've spent a considerable ammount of time researching the issue. Why so much pain in integrating a library that should be usable out of the box.

Is it possible to get ONLY action bar with the support v7 library?

Community
  • 1
  • 1
Mister Smith
  • 27,417
  • 21
  • 110
  • 193
  • I got it working in my app though I must say the documentation was not very helpful and it required research. I'll check my code when I'll have access to my computer. – Szymon Nov 13 '13 at 10:13
  • just noticed my target was 2.2 changing to 4.3 did the trick! – Muhammad Babar Sep 30 '14 at 08:00
  • 1
    This f**king error occurs each time I add nearly created project to my git repository. Tried everything to resolve the issue, nothing helps. Spend days to resolve. It seems that they want us to waste more time on it. – burseaner Nov 24 '14 at 13:08

3 Answers3

13

Finally got it working.

When adding ActionBarSherlock, the same kind of errors where appearing in the console.

I've edited the project.properties file (yeah, that one with the comment "This file is automatically generated by Android Tools. Do not modify this file -- YOUR CHANGES WILL BE ERASED") Build target was set to 8, changed it to 16 and now it compiles with both ABS and appcompat v7.

UPDATE:
Here's how to do it the right way: https://stackoverflow.com/a/3343050/813951

Community
  • 1
  • 1
Mister Smith
  • 27,417
  • 21
  • 110
  • 193
  • Thanks you so much. I was starting to get really frustrated. – ProgMasta Jan 13 '14 at 06:49
  • Also, for whoever encounter the same error (like me) but with no success of the above solution: make sure that you have imported ALL libraries for appcompat (I did only android-support-v7-appcompat skipping the mediarouter and gridlayout - but I used sample project that required those:) – Lukasz 'Severiaan' Grela Jan 23 '14 at 09:25
  • The trick is to actually BUILD your project with a higher API Level as you want it to run on the target devices. just as a hint: what you've done by hand in the "DO-NOT-EDIT" file can easily be done through the project settings in the eclipse-UI where you can set the API Level ;) In the end it makes totally sense to build with a higher API level since the support-libraries can then use the native features on a high level SDK phone and the support features on low api-level phones. – dy_ Jan 30 '14 at 01:13
  • @datayeah In case you didn't see it, I posted a link to the proper way of doing this in the update long time ago. And about building with a higher API, I think it is dangerous, because it is easy to make API calls that are not available for the oldest supported devices. – Mister Smith Jan 30 '14 at 13:53
0

Have to look at ActionBarSherlock, it really helps, since your root request is add the action bar for devices 2.3 and higher

In my project, it works with android 2.2 to 4.x

RRTW
  • 3,160
  • 1
  • 35
  • 54
0

When using Android Studio and build.gradle setup: bump up compileSdkVersion >= 14.

Daniel Dudek
  • 515
  • 7
  • 17