style_base.xml 文件中的错误 - android 应用程序 - 找不到与给定名称“android:Widget.Material.ActionButton"匹配的资源 [英] Error in styles_base.xml file - android app - No resource found that matches the given name 'android:Widget.Material.ActionButton'

查看:29
本文介绍了style_base.xml 文件中的错误 - android 应用程序 - 找不到与给定名称“android:Widget.Material.ActionButton"匹配的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我是 android 开发的初学者,我刚刚创建了 hello world 应用程序.但是它在 appcompat_v7 库的 styles_base.xml 文件中给了我错误.

Ok, so im a beginner in android development and I just created the hello world app. But it's giving me errors in styles_base.xml file of appcompat_v7 library.

错误:检索项目的父项时出错:找不到资源匹配给定的名称'android:Widget.Material.ActionButton'.style_base.xml/appcompat_v7/res/values-v21
AAPT问题

error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'. styles_base.xml /appcompat_v7/res/values-v21
AAPT Problem

我该如何处理这个错误?另外为什么在我不想要的时候使用 appcompat_v7 库?我的意思是如何在不使用 appcompat_v7 库的情况下创建 hello world 应用程序?

How do i take care of this error? Also why is the appcompat_v7 library being used when I don't want it? I mean how do I create the hello world app without using the appcompat_v7 library?

这是给出上述错误的 styles_base.xml 文件.

This is the styles_base.xml file which is giving the above error.

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


这是我正在使用的代码:


This is the code I'm using:

public class MainActivity extends Activity {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
   }
}

推荐答案

转到你的 Android SDK 安装目录然后 extras > android > support > v7 > appcompat.

Go to your Android SDK installed directory then extras > android > support > v7 > appcompat.

就我而言:D:Softwareadt-bundle-windows-x86-20140702sdkextrasandroidsupportv7appcompat

in my case : D:Softwareadt-bundle-windows-x86-20140702sdkextrasandroidsupportv7appcompat

进入 appcompat 文件夹后,检查 project.properties 文件,然后将值从默认 19 更改为 21 为:

once you are in appcompat folder ,check for project.properties file then change the value from default 19 to 21 as :

target=android-21.

保存文件,然后刷新您的项目.

Save the file and then refresh your project.

然后清理项目:在项目选项卡中,选择清理选项,然后选择您的项目并清理...

Then clean the project: In project tab , select clean option then select your project and clean...

这将解决错误.如果没有,请确保您的项目也面向 API 21 或更高版本(与以前相同的步骤,并且在升级面向旧版本的项目时很容易忘记).享受编码...

This will resolve the error. If not, make sure your project also targets API 21 or higher (same steps as before, and easily forgotten when upgrading a project which targets an older version). Enjoy coding...

这篇关于style_base.xml 文件中的错误 - android 应用程序 - 找不到与给定名称“android:Widget.Material.ActionButton"匹配的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆