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?
In the Properties window, select the "Android" properties group at left and locate the Library properties at right. Select /path/to/appcompat/ and Click Remove. Click Add to open the Project Selection dialog. From the list of available library projects, select v7 appcompat library and click OK.
In the Library pane, click the Add button. Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-cardview . In the properties window, click OK (or Apply and Close).
Downloading the Support LibrariesStart the android SDK Manager. In the SDK Manager window, scroll to the end of the Packages list, find the Extras folder. Select the Android Support Library item. Click the Install packages button.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With