3

I need to implement the actionbar in Android 2.x I've tried with this post and setup the support library as mentioned in thisofficial article.

Here are the steps that I've followed for implement the ActionBar using the appcompat support library:

First, I create the project with the following configuration (I don't create an icon and a default activity):

Minimum Required SDK: API 10: Android 2.3.3 (Gingerbread)
Target SDK: API 19: Android 4.4
Compile with: API 10: Android 2.3.3 (Gingerbread)
Theme: None

After, in the Project properties => Android => Library I add the android-support-v7-appcompat library project.

After this, I get 128 errors like this in the project where I use the appcompat library. All of them are related with the Holo theme:

[2013-12-06 13:24:24 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\styles_base.xml:24: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar'.  

Please, note that the error only occurs with the values-v14 and values-v11 folders in the appcompat library project. Here are 2 examples of the errors I get:

[2013-12-06 13:24:24 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\styles_base.xml:100: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionBar.Subtitle.Inverse'.  
[2013-12-06 13:24:24 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v11\styles_base.xml:26: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ProgressBar.Horizontal'.  

Also, there are few error not related with the Holo theme:

[2013-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\styles_base.xml:225: error: Error: No resource found that matches the given name: attr 'android:dividerPadding'.  
[2013-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\styles_base.xml:224: error: Error: No resource found that matches the given name: attr 'android:showDividers'.  
[2013-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\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-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\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-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\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-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\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-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\themes_base.xml:94: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.  

Has anyone had the same problem?

richsage
  • 26,912
  • 8
  • 58
  • 65
Jorge E. Hernández
  • 2,800
  • 1
  • 26
  • 50

5 Answers5

15

Set "Compile with" to API Level 19 as well - when you compile your app with SDK level 10, the compiler doesn't know the elements shown in the error log.

Julia Hexen
  • 695
  • 3
  • 10
  • Thanks a lot dude! :D This save almost a week of work... :$ There are a lot of tutorials but they don't explain this simple configuration. Hope this helps someone else. :D – Jorge E. Hernández Dec 12 '13 at 03:01
2

You need to reference the res directory from AppCompat to your project. There you can find all resource files, which are needed for the Support ActionBar.

How to add those resource files is described pretty good on the google developer site: http://developer.android.com/tools/support-library/setup.html

Scroll down to :"Adding libraries with resources". Follow the instructions and everything should be fine ;)

blackfizz
  • 822
  • 8
  • 21
0

As blackfizz said, http://developer.android.com/tools/support-library/setup.html should give you a good how-to on how to setup the library in Eclipse.

On another note though: I can highly recommend using Android Studio IDE, as it supports the gradle build system which will enormously help with your struggle with setting up the different libraries. If you're using gradle, all you have to do is add:

dependencies {
    ...
    compile "com.android.support:appcompat-v7:18.0.+"
}

to your build.gradle file and gradle will do the rest for you. Other third party libraries can also be added super easily. They'll automatically be resolved through Maven Central.

I've switched over to Android Studio IDE with gradle a few weeks ago and I never want to miss it again.

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
MrMaffen
  • 1,647
  • 1
  • 17
  • 22
0
  1. Right click -> Property -> Switch tab to Android -> Select project build target api level 16

  2. Add android:targetSdkVersion="16" in manifest file.

Your manifest looks like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="android.support.v7.appcompat">
    <uses-sdk android:minSdkVersion="7"
        android:targetSdkVersion="16"/>
    <application />
</manifest>
  1. Clean and build library project.

That's IT.

Hiren Patel
  • 52,124
  • 21
  • 173
  • 151
0

Go to Manifest.xml file of your project. Then set android:minSdkVersion="11". It will solve your problem. Late reply but may be helpful for others.

Rameshbabu
  • 611
  • 2
  • 7
  • 21