I write a theme in styles.xml file like below
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Root styles that vary by API level -->
<style name="FrameworkRoot.Theme" parent="Theme.Sherlock.Light.DarkActionBar">
<!-- API 11+ (compatibility) -->
<item name="buttonBarStyle">@style/Compat.ButtonBar</item>
<item name="buttonBarButtonStyle">@style/Compat.ButtonBarButton</item>
<item name="indeterminateProgressStyle">@style/Compat.IndeterminateProgress</item>
<!-- API 14+ (compatibility) -->
<item name="listPreferredItemPaddingLeft">@dimen/compat_list_preferred_item_padding_left</item>
<item name="listPreferredItemPaddingRight">@dimen/compat_list_preferred_item_padding_right</item>
<item name="listPreferredItemHeightSmall">@dimen/compat_list_preferred_item_height_small</item>
</style>
but get the error: Error: No resource found that matches the given name: attr 'buttonBarStyle'.
I get the code from the google io2012. Both mine and its' all base
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
I can compile the google io2012's source code but not mine. so strange. is anybody know why? or have the same question?
I had a similar problem... I have two projects in my Eclipse workspace, both based on the Android 4.2 jar. One has minSdkVersion="8" with targetSdkVersion="17" and its style references both the
buttonBarStyle
andbuttonBarButtonStyle
names just fine. The other project uses the same manifest settings and will not build due to the errors:When I saw
@dead's
comment about needing anattrs.xml
file, I checked and sure enough, the project that wouldn't compile was missing this file. I think the working project was generated using the Eclipse Android Application Project wizard, while the other was created manually.The contents of
res/values/attrs.xml
:The contents of
res/values/colors.xml:
And the three style files:
1) res/values/styles.xml
2) res/values-v11/styles.xml
3) res/values-v14/styles.xml
Had the same problem as yours:
my
build.gradle
file:what I did in my Values folder added a
attrs.XML
file, with this codes in it:now I see no complains!
I was getting same error....deleted the folders at
C:\Users\.android\build-cache\Hash Number of Folders E.g. 4eaccf0d162ec009b115c7e0ff4f542f8d2a663b\
and it worked like a charm....
Make sure you have included the AppCompat . It is a library project. You need to reference the library project in your android project.
https://developer.android.com/tools/support-library/setup.html
Check the topic Adding libraries with resources.
Refer the below link. Add the values which are used in your code and delete the rest . Hope it helps you.
https://android.googlesource.com/platform/frameworks/base/+/2888524e03896831f487e5dee63f18f1c33c0115/core/res/res/values/attrs.xml
buttonBarStyle
is for versions 11 and above as you state in your SDK but you are usingandroid:minSdkVersion="8"
. Isn't it supposed to work forandroid:minSdkVersion="11"
?