error: Error: No resource found that matches the given name: attr 'buttonBarButtonStyle'

Viewed 64268

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?

6 Answers

Had the same problem as yours:

my build.gradlefile:

android {
compileSdkVersion 25
buildToolsVersion "27.0.1"
defaultConfig {
    applicationId "com.whatever"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}}

what I did in my Values folder added a attrs.XML file, with this codes in it:

<declare-styleable name="ButtonBarContainerTheme">
    <attr name="metaButtonBarStyle" format="reference" />
    <attr name="metaButtonBarButtonStyle" format="reference" />
</declare-styleable>

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....

Related