AppCompat v7 r21在values.xml中返回错误?


281

我正在使用Android Studio,当我将其添加compile "com.android.support:appcompat-v7:21.0.0" 到Gradle文件中时,出现很多错误:

C:\Users\WindowsSucks\AndroidStudioProjects\MMMeds\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0\res\values-v11\values.xml
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Users\WindowsSucks\AndroidStudioProjects\MMMeds\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0\res\values-v14\values.xml
Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Users\WindowsSucks\AndroidStudioProjects\MMMeds\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0\res\values-v21\values.xml
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display3'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Headline'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Menu'.
Error:Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Subtitle'.
Error:Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Title'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Subhead'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Title'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Menu'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title.Inverse'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Subtitle'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Title'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.ActionBar'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Dark'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Dark.ActionBar'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Light'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabText'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabView'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.CloseMode'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.Overflow'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.AutoCompleteTextView'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.DropDownItem.Spinner'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabView'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.AutoCompleteTextView'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.PopupMenu'.
Error:(298, 21) No resource found that matches the given name: attr 'android:overlapAnchor'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListPopupWindow'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView.DropDown'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.PopupMenu'.
Error:(298, 21) No resource found that matches the given name: attr 'android:overlapAnchor'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Toolbar.Button.Navigation'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Dialog'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.Dialog'.
Error:(144, 21) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(146, 21) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(147, 21) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(145, 21) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(142, 21) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(143, 21) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(144, 21) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(146, 21) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(147, 21) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(145, 21) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(142, 21) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(143, 21) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(144, 21) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(146, 21) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(147, 21) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(145, 21) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(142, 21) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(143, 21) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(144, 21) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(146, 21) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(147, 21) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(145, 21) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(142, 21) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(143, 21) No resource found that matches the given name: attr 'android:colorPrimaryDark'.

所有这些似乎都显示在:

\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0\res\values-v11\values.xml

\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0\res\values-v21\values.xml

6
您的compileSdkVersion是否设置为21?
ianhanniballake 2014年

否,我有“ compileSdkVersion 20 buildToolsVersion” 20.0.0“”是否需要将buildToolsVerison更改为21?@ianhanniballake
Michael Garber

使用eclipse时也会出现错误
Iftikar Urrhman Khan 2015年

您应该始终将依赖项更新为最新版本,即appcompat-v7:21.0.3。
IgorGanapolsky

1
@IgorGanapolsky无法解析符号'机器人:Theme.Material.Light'在<样式名称= “AppBaseTheme”父= “机器人:Theme.Material.Light”> </风格>在valules-V21
潘卡Nimgade

Answers:


427

AppCompat v21构建需要API 21(Android 5.0)中提供的新API的主题。要使用AppCompat编译应用程序,您还必须针对API 21进行编译。建议使用API​​ 21进行编译/构建的设置是compileSdkVersion of 21and buildToolsVersionof 21.0.1(这是目前最高的-您一直想使用最新的构建工具) 。


6
但是这样做是否会使我的应用与旧版本不兼容?我希望我的应用程序可以追溯到sdk 15
Michael Garber 2014年

45
compileSdkVersionminSdkVersion(控制您可以说您的应用程序可以运行的最低级别)和targetSdkVersion(控制所有自动应用的向后兼容功能-如果您到目前为止尚未在最新的API上测试您的应用程序很重要)完全不同。
ianhanniballake 2014年

18
有什么建议,如果您已经知道了,但仍然出现错误?我compileSdkVersion只有21岁buildToolsVersion21.0.1但没有运气。
2014年

7
@engico不幸的是,这对我来说还没有做到。我现在在21.0.2,仍然没有运气。
汤姆(Tom)

2
谢谢@Sver,不幸的是我删除了所有库,但没有成功。只有@shider更改为的解决方案appcompat-v7:20.0.0有效,但是该版本没有我想要的所有功能,因此毫无意义。我还确认了这是在一个空白项目中发生的,该项目是appcompat-v7:21.0.0使用新的Build Tools全新的21
汤姆

43

确保为价值目标中(它告诉目标Android版本)project.properties文件 项目文件夹和appcompat_v7文件夹是相同的(最好是最新的)。

:在'your_project'/ project.properties中

target=android-21 android.library.reference.1=../appcompat_v7

:在appcompat_v7 / project.properties内部

target=android-21 android.library=true

之后,别忘了清理您的项目。


1
谢谢GiriB!这对我来说很合理。我的项目的目标构建比appcompat文件夹低。
GraSim 2015年

感谢@GiriB,这也对我有用。我的项目的目标版本比appcompat lib项目的目标版本低。
Bharat Dodeja'3

18

更改compile 'com.android.support:appcompat-v7:21.0.0'compile 'com.android.support:appcompat-v7:20.0.0'gradle.build对我有用。


1
是的,它有效。但防止您使用程序兼容性-V7:21.0.0
Sver

这是唯一对我有用的解决方案,但它是有限的。我不确定为什么会这样。
汤姆

@Sver,不能解析符号'机器人:Theme.Material.Light'在<样式名称= “AppBaseTheme”父= “机器人:Theme.Material.Light”> </风格>在valules-V21
潘卡Nimgade


7

将complie SDk版本更改为API级别21后,为我修复了该问题。然后我遇到了其他将应用程序部署到我的设备的问题。我更改了最小的API级别以定位到我想要的东西,并对其进行了修复。

万一有人再次遇到这种情况。



4

我的solucion与其他版本一起编译

build.gradle(应用程序)

compileSdkVersion 21

祝好运



3

我投票表决谁能像我一样解决。我和你有同样的问题,我花了很多时间来纠正。请测试一下。

升级整个SDK,更新21.0.2版本也具有Google Services的更新。升级一切。在您的工作区中删除文件夹(android -support- v7-AppCompat)和(google -play-services_lib)

将这些项目重新导入到IDE中,然后选择再次将它们复制到您的工作区中。

执行刷新和构建操作的项目(google -play-services_lib)

**** *****问题项目(android -support-v7-AppCompat)标记为5.0 API,然后刷新并生成。

在他的项目中,在属性android中,导入库(android -support-v7-AppCompat)和(google -play-services_lib),然后刷新并生成。


,不能解析符号'机器人:Theme.Material.Light'在<样式名称= “AppBaseTheme”父= “机器人:Theme.Material.Light”> </风格>在valules-V21
的Pankaj Nimgade

3

如果您不想使用API​​ 21,则可以使用旧版本的appcompact库,而无需更新就使用旧的应用程序压缩库。

您只需执行以下步骤即可实现:

1)解压缩完整的sdk和eclipse软件包的下载版本。

2)只需从中导入appCompact库 sdk\extras\android\support\v7\appcompact

现在您完成了。


@Perroloco没有得到你??
DjP 2014年

它是AppCompat。Compat是“兼容/兼容性”的简称。:)
SlashG

2

我已经更新了build.gradle(Module:app):旧代码:

  compile 'com.android.support:appcompat-v7:23.0.1'

新代码:

 compile 'com.android.support:appcompat-v7:22.2.0'

在android studio中为我工作。



1

嗨,我在appcompatv7库中遇到了相同的错误,我按照@ianhanniballake的建议进行了操作,并通过选择库并单击鼠标的辅助按钮单击来检查库的构建版本:

属性-> Android-> Android 5.0.1 API级别21

然后清理所有项目,但是我没有运气,所以在失去了所有希望之后,我决定从Eclipse Kepler升级到Eclipse Luna。

在等待下载完成时。我决定尝试另一件事,因此我从Eclipse appcompatv7库中删除并检查了

删除磁盘上的项目内容。

打开Android SDK来检查是否有任何更新,然后通过选择我的项目,然后在

项目->属性-> Android->库部分

删除了所有库,包括开始所有此问题的库

Google_Play_Services_Lib

然后重新启动Eclipse并从Android SDK复制。文件夹appcompat来自:

android-sdk-linux / extras / android / support / v7

到我的eclpse工作区,然后从工作区中的Import exsting项目将其导入到Eclipse中,然后选择适当的构建工具版本

Android 5.0.1 API 21

并添加了我所有的参考库,清理了所有项目,并再次完成了所有工作。

我为所有参考库选择了相同的构建工具。

希望这可以帮助!!!!

顺便说一句,我试图进行投票,但是我没有足够的代表来投票。


1

当我遇到相同的问题时,请检查是否在此处添加了Google Play服务 ,并删除了所有内容,然后按照步骤操作,一切正常。


1

我遇到了同样的问题,并在我的build.gradle compileSdkVersion 21,targetSdkVersion 21和 buildToolsVersion 21.0.1中具有正确的API级别值

但是,我将其作为模块包含在我的项目中,因此我必须确保其他模块gradle设置与API 21相匹配。之后,所有这些都对我有用。



1

以Eclipse IDE为例,我遇到了同样的问题,解决方案是:
1-安装最新的可用API(SDK平台和Google API)
2-使用以下设置创建项目:

  • 编译方式:使用当时可用的最新API版本
  • 其他值可以根据您的要求接收值(请查看前面的注释中每个值的含义)

1

对我来说,这是:

android {
compileSdkVersion 21
buildToolsVersion '23.0'

defaultConfig {
    applicationId "nl.changer.polypickerdemo"
    minSdkVersion 15
    targetSdkVersion 21
---------
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'


}

我修改了:compileSdkVersion 21 buildToolsVersion '23 .0'appcompat-v7:22.2.0'


1

导入google-services.json文件以实施Analytics时,我遇到了这个问题。我在xml文件夹中已经有global_tracker.xml文件。在构建期间,在合并google-services.json文件中的内容时,错误开始出现。暂时,删除goolgle-services.json文件后,该错误已解决。并使用较旧的Google Analytics(分析)解决方案。

检查您最后一次编辑/导入的XML或Json文件,也许您会在此处提交错误。这就是我的情况。


1

这帮助了我

  • 将Android SDK更新到最新版本
  • app/build.gradle使用最新组件进行更新:

    compileSdkVersion 25  
    buildToolsVersion "25.0.2"  
    minSdkVersion 17  
    targetSdkVersion 25

希望这能解决您的问题


1

这对我来说很好。转到android-support-v7-appcompat项目并打开文件“ project.properties”,如果缺少该行,请插入以下行:

target=android-25
compile=android-21


1

我的一个phonegap项目面临同样的问题。为了解决这个问题,我遵循了以下步骤

1)右键单击项目名称(在我的情况下为android),选择“打开模块设置”

2)选择模块(android和CordovaLib)

3)点击顶部的属性

4)选择Compose SDK版本(我选择了API 26:Android 8.0)

5)选择构建工具版本(我选择了26.0.2)

6)源兼容性(1.6)

7)目标相容性(1.6)

单击确定,然后重建项目。

还有一个额外的步骤

编译'com.android.support:appcompat-v7:27.0.2'

build.gradle(模块:android)

以下链接显示了我遵循的步骤设置

https://app.box.com/s/itkkjz09wgy36jwowhvzcyx6fp7o2gkh

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.