1

I am a newbie at android development.I created a new project but along with it appcompat_v7 also got created.Now my project does not run since appcompat_v7 has errors. The error is only in the appcompat_v7-> res-> values-v21-> style_base.xml on the following line

<style name="Base.Widget.AppCompat.ActionButton"
           parent="android:Widget.Material.ActionButton">
  </style>

with the description

Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'

I have tried cleaning and rebuilding the project but the error persists.How do I fix this?

Here is the appcompat_v7 -> res -> values-v21 -> styles.xml This file is the one with the error on line 75: Error:

<style name="Base.Widget.AppCompat.ActionButton"
           parent="android:Widget.Material.ActionButton">
    </style>

This is the file

<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2014 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<resources>

    <!-- Like in themes_base.xml, the namespace "*.AppCompat.Base" is used to
     define base styles for the platform version. The "*.AppCompat"
     variants are for direct use or use as parent styles by the app. -->
    <eat-comment/>

    <style name="Base.Widget.AppCompat.ActionBar.TabView"
           parent="android:Widget.Material.ActionBar.TabView">
    </style>

    <style name="Base.Widget.AppCompat.Light.ActionBar.TabView"
           parent="android:Widget.Material.Light.ActionBar.TabView">
    </style>

    <style name="Base.Widget.AppCompat.ActionBar.TabText"
           parent="android:Widget.Material.ActionBar.TabText">
    </style>

    <style name="Base.Widget.AppCompat.Light.ActionBar.TabText"
           parent="android:Widget.Material.Light.ActionBar.TabText">
    </style>

    <style name="Base.Widget.AppCompat.Light.ActionBar.TabText.Inverse"
           parent="android:Widget.Material.Light.ActionBar.TabText">
    </style>

    <style name="Base.TextAppearance.AppCompat.Widget.ActionBar.Menu"
           parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
    </style>

    <style name="Base.TextAppearance.AppCompat.Widget.ActionBar.Title"
           parent="android:TextAppearance.Material.Widget.ActionBar.Title">
    </style>

    <style name="Base.TextAppearance.AppCompat.Widget.ActionBar.Subtitle"
           parent="android:TextAppearance.Material.Widget.ActionBar.Subtitle">
    </style>

    <style name="Base.TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"
           parent="android:TextAppearance.Material.Widget.ActionBar.Title.Inverse">
    </style>

    <style name="Base.TextAppearance.AppCompat.Widget.ActionBar.Subtitle.Inverse"
           parent="android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse">
    </style>

    <style name="Base.TextAppearance.AppCompat.Widget.ActionMode.Title"
           parent="android:TextAppearance.Material.Widget.ActionMode.Title">
    </style>

    <style name="Base.TextAppearance.AppCompat.Widget.ActionMode.Subtitle"
           parent="android:TextAppearance.Material.Widget.ActionMode.Subtitle">
    </style>

    <!-- Action Button Styles -->

    <style name="Base.Widget.AppCompat.ActionButton"
           parent="android:Widget.Material.ActionButton">
    </style>

    <style name="Base.Widget.AppCompat.ActionButton.CloseMode"
           parent="android:Widget.Material.ActionButton.CloseMode">
    </style>

    <style name="Base.Widget.AppCompat.ActionButton.Overflow"
           parent="android:Widget.Material.ActionButton.Overflow">
    </style>

    <!--
        Widget.AppCompat.Toolbar style is purposely ommitted. This is because the support
        Toolbar implementation is used on ALL platforms and relies on the unbundled attrs.
        The supporting Toolbar styles below only use basic attrs so work fine.
    -->

    <style name="Base.Widget.AppCompat.Toolbar.Button.Navigation"
           parent="android:Widget.Material.Toolbar.Button.Navigation">
    </style>

    <style name="Base.TextAppearance.Widget.AppCompat.Toolbar.Title"
           parent="android:TextAppearance.Material.Widget.ActionBar.Title">
    </style>

    <style name="Base.TextAppearance.Widget.AppCompat.Toolbar.Subtitle"
           parent="android:TextAppearance.Material.Widget.ActionBar.Subtitle">
    </style>

    <!-- Spinner Widgets -->

    <style name="Base.Widget.AppCompat.ListView.DropDown"
           parent="android:Widget.Material.ListView.DropDown"/>

    <style name="Base.Widget.AppCompat.DropDownItem.Spinner"
           parent="android:Widget.Material.DropDownItem.Spinner"/>

    <style name="Base.Widget.AppCompat.Spinner" parent="android:Widget.Material.Spinner" />

    <style name="Base.Widget.AppCompat.Spinner.DropDown.ActionBar" parent="android:Widget.Material.Spinner">
        <item name="spinnerMode">dropdown</item>
        <item name="disableChildrenWhenDisabled">true</item>
        <item name="popupPromptView">@layout/abc_simple_dropdown_hint</item>
    </style>

    <style name="Base.Widget.AppCompat.ListView.Menu"
           parent="android:Widget.Material.ListView" />

    <!-- Popup Menu -->

    <style name="Base.Widget.AppCompat.ListPopupWindow" parent="android:Widget.Material.ListPopupWindow">
    </style>

    <style name="Base.Widget.AppCompat.PopupMenu" parent="android:Widget.Material.PopupMenu">
    </style>

    <style name="Base.Widget.AppCompat.Light.PopupMenu"
        parent="android:Widget.Material.Light.PopupMenu">
    </style>

    <style name="Base.Widget.AppCompat.PopupMenu.Overflow">
        <item name="android:dropDownHorizontalOffset">-4dip</item>
        <item name="android:overlapAnchor">true</item>
    </style>

    <style name="Base.Widget.AppCompat.Light.PopupMenu.Overflow">
        <item name="android:dropDownHorizontalOffset">-4dip</item>
        <item name="android:overlapAnchor">true</item>
    </style>

    <style name="Base.TextAppearance.AppCompat.Widget.PopupMenu.Large"
        parent="android:TextAppearance.Material.Widget.PopupMenu.Large">
    </style>

    <style name="Base.TextAppearance.AppCompat.Widget.PopupMenu.Small"
        parent="android:TextAppearance.Material.Widget.PopupMenu.Small">
    </style>

    <style name="Base.TextAppearance.AppCompat.Light.Widget.PopupMenu.Large"
        parent="android:TextAppearance.Material.Widget.PopupMenu.Large">
    </style>

    <style name="Base.TextAppearance.AppCompat.Light.Widget.PopupMenu.Small"
        parent="android:TextAppearance.Material.Widget.PopupMenu.Small">
    </style>

    <!-- Search View result styles -->

    <style name="Base.TextAppearance.AppCompat.SearchResult.Title"
           parent="@android:TextAppearance.Material.SearchResult.Title">
    </style>

    <style name="Base.TextAppearance.AppCompat.SearchResult.Subtitle"
           parent="@android:TextAppearance.Material.SearchResult.Subtitle">
    </style>

    <style name="Base.Widget.AppCompat.AutoCompleteTextView" parent="android:Widget.Material.AutoCompleteTextView" />

    <style name="Base.Widget.AppCompat.Light.AutoCompleteTextView" parent="android:Widget.Material.AutoCompleteTextView" />

    <!-- Progress Bar -->

    <style name="Base.Widget.AppCompat.ProgressBar.Horizontal"
           parent="android:Widget.Material.ProgressBar.Horizontal">
    </style>

    <style name="Base.Widget.AppCompat.ProgressBar"
           parent="android:Widget.Material.ProgressBar">
    </style>

    <!-- TODO. Needs updating for Material -->
    <style name="Base.Widget.AppCompat.ActivityChooserView" parent="">
        <item name="android:gravity">center</item>
        <item name="android:background">@drawable/abc_ab_share_pack_holo_dark</item>
        <item name="android:divider">?attr/dividerVertical</item>
        <item name="android:showDividers">middle</item>
        <item name="android:dividerPadding">6dip</item>
    </style>

</resources>

This is myproject -> res -> values -> styles.xml

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

</resources>
cyclops
  • 41
  • 1
  • 2
  • 10
  • @Funkystein I tried that too.But again I get the same error since the following style tags contain the same value for parent attribute and I am not keen on deleting all the style tags since they are for the action button and I might encounter problems later into the project. – cyclops Oct 30 '14 at 15:49

6 Answers6

0

Check you Build targets in both your project and appcompat. Your project must not be less than the target of appcompat which, I think needs SDK 10 or newer:

In Eclipse go to Project->Properties->Android (Project Build Target)

mmeyer
  • 3,598
  • 1
  • 19
  • 22
0

Somebody else had the same problem, you need to install Java 1.8

See this link: https://stackoverflow.com/a/26642124/2767703

Community
  • 1
  • 1
Kevin van Mierlo
  • 9,554
  • 5
  • 44
  • 76
  • can you please specify how to add Theme.AppCompat and Widget.AppCompat to my styles.xml file because installing Java 8 is not working for me :( – cyclops Oct 30 '14 at 17:21
  • Check out this link: http://android-developers.blogspot.nl/2014/10/appcompat-v21-material-design-for-pre.html Go to the chapter theming. Parent should be: `Theme.AppCompat.Light` or with darkactionbar. If you still didn't manage to make it work, add your entire styles.xml and comment again. – Kevin van Mierlo Oct 30 '14 at 18:21
  • @cyclops First of all I'd recommend switching to Android Studio. It works great! But if you still want eclipse try this: Go to project properties (right click project -> properties) -> Java Compiler and change JDK to 1.8 (If this is not visible try 1.7 or download the JDK 1.8 again) – Kevin van Mierlo Oct 31 '14 at 09:01
0

when Android Lollipop has launched, eclipse and sdk manager also upgraded but

SDK 5.0(Lollipop) has issues about v7 (appcompat, cardview ... ) - doesn't found resource or matched.

this link

Using android.support.v7.widget.CardView in my project (Eclipse)

http://happilycoded.com/blog/using-recyclerview-and-cardview-in-eclipse-adt/

or this will help you

Community
  • 1
  • 1
HWANG
  • 249
  • 4
  • 10
0

To resolve this issue,

  1. Right Click on appcompat_v7 library and select Properties
  2. Click on Android Option,
  3. Set Project Build Path as Android 5.0 (API level 21)
  4. Apply Changes.
  5. Go to project.properties file under appcompat_v7 library,
  6. Set the project target as : target=android-21
  7. Clean + Build appcompat_v7 library and your projects

See here

rtruszk
  • 3,902
  • 13
  • 36
  • 53
alright
  • 59
  • 6
0

Right-Click on the appcompat project folder and open "properties". Go to "Android" section and check "Android 5.0" as the project build target apply it and enjoy :)

0

Hope this approach will help you.

Update the project.properties file of appcompat v7, which has:target=android-19 to target=android-23. Always target to upper version.

ShutterSoul
  • 2,551
  • 3
  • 23
  • 28