0

i am sorry that i am repeating the same question asked by many people. I have devloped my small application using API 19 with no problem. But after i have updated it to API 21, i have many errors.

The following is where i get the error evreytime:

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

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

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

I also get R cannot be resolved to type and i donot get the R.java generated after i clean and build th project. I have done this more than 10 times by now.

Please anyone help me.

Here's my styles_base.xml file:

<?xml version="1.0" encoding="utf-8"?>
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. -->

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

My Manifest.xml is:

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.hos"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
user2720828
  • 81
  • 2
  • 10

2 Answers2

0

Possible Eclipse Solution

In your res folder there is another folder called values, there is a file called styles.xml. In this file you put these values: Theme.AppCompat and Widget.AppCompat. These are the compatibility from the appcompat v21 library.


Android Studio Solution

I had the same problem, you should do this:

  1. Change compileSdkVersion in build.gradle within the app to compileSdkVersion 21
  2. Change buildToolVersion in build.gradle within the app to buildToolVersion 21.0.2 (This is the latest build tool version, so you have to have it installed)
  3. Sync the gradle files and it should work

Kevin van Mierlo
  • 9,554
  • 5
  • 44
  • 76
  • @user2720828 I changed my answer. Sorry this was for Android Studio. I'd recommend switching to Android Studio btw. Works like a charm. I'll try to find the answer for eclipse – Kevin van Mierlo Oct 29 '14 at 17:55
  • @user2720828 Do you have a values-v21 in your project? If you don't make it. Make a file named styles. Put in the same as the styles file in your normal values folder. In the normal styles file put `Theme.AppCompat` and `Widget.AppCompat` and in the v21 file `android:Theme.Material` and `android:Widget.Material` – Kevin van Mierlo Oct 29 '14 at 18:05
  • i didn't get you exactly, can you explain it clearly? should i create a folder values-v21 in my project and create a styles.xml file and copy all the contents of the styles_base.xml file present in appcompat_v7 project? – user2720828 Oct 29 '14 at 18:21
  • @user2720828 I changed my answer, explained it in detail. – Kevin van Mierlo Oct 29 '14 at 18:31
  • I still didnt get you.I am very new to android. Should i add them like this: – user2720828 Oct 29 '14 at 18:52
  • @user2720828 Can you post your full styles.xml? - Side note: I'm not sure if it is a great idea to immediately start with this library when you're new to Android. Maybe you should start with learning the basics of Android first – Kevin van Mierlo Oct 29 '14 at 18:53
  • I have posted my styles.xml file. Iam in fact learning android by creating different functions using API 19. but when i have updated it to api 21, i started getting these errors in the appcompat_v7/res folder. – user2720828 Oct 29 '14 at 19:02
  • @user2720828 have you done this: http://stackoverflow.com/a/18969475/2767703 - Can you post the full code of the actionbutton style? Also what is your minimum sdk version and target sdk version? – Kevin van Mierlo Oct 29 '14 at 19:33
  • I posted all my files. Its really simple program and don't know why am i getting this error. – user2720828 Oct 29 '14 at 20:58
0

The reason i was getting this error is because I didn't install Java 1.8 which is required for android 5.0. I installed, cleaned the projects and build them. The error was gone. @Kevin van Mierlo Thank you for your time. :)

user2720828
  • 81
  • 2
  • 10