appcompat-V7:21.0.0“:没有资源的发现,匹配给定的名字:ATTR”机器人:actionModeShareDrawable“ [英] appcompat-v7:21.0.0': No resource found that matches the given name: attr 'android:actionModeShareDrawable'

查看:297
本文介绍了appcompat-V7:21.0.0“:没有资源的发现,匹配给定的名字:ATTR”机器人:actionModeShareDrawable“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试使用最新的appcompat-V7支持库在我的项目,我得到以下错误:

<$p$p><$c$c>/Users/greg/dev/mobile/android_project/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/values-v11/values.xml 错误:(36 21)否资源发现,匹配给定的名字:ATTR机器人:actionModeShareDrawable。 错误:(36 21)否资源发现,匹配给定的名字:ATTR机器人:actionModeShareDrawable。 错误:(36 21)否资源发现,匹配给定的名字:ATTR机器人:actionModeShareDrawable。 错误:(36 21)否资源发现,匹配给定的名字:ATTR机器人:actionModeShareDrawable。

我该如何解决这个问题?

解决方案

虽然 loeschg 答案是绝对正确的我只是想阐述,并给了一个解决方案的所有IDE的(Eclipse中,IntellJ和Android工作室),即使错误略有差异。


prerequirements

请确保你已经下载了最新的演员还有的Andr​​oid 5.0 SDK 通过SDK-经理。


Android的工作室

打开您的应用程序模块的 build.gradle 文件,并改变你的 compileSdkVersion 来21.它基本上不必须把 targetSdkVersion SDK-版本更改为21,但它的建议,因为你要经常针对最新的Andr​​oid内建版本
你到底摇篮文件将是这样的:

 安卓{
    compileSdkVersion 21
    // ...

    defaultConfig {
        // ...
        targetSdkVersion 21
    }
}
 

请务必事后同步您的项目。


的Eclipse

在Eclipse中使用 V7-appcompat 你必须把它作为一个库项目。这是不够的的* .jar只复制到您的 /库文件夹。请阅读这个(点击)一步一步的教程上的<为了知道如何正确导入项目EM> developer.android.com 的。

一旦该项目进口的,你就会意识到,在 / RES 文件夹中的一些文件夹是红色的下划线,因为错误,如下面的:

 错误:错误检索父项:未发现的资源匹配给定名称机器人:TextAppearance.Material。
错误:错误检索父项:未发现的资源匹配给定名称机器人:Widget.Material *
错误:错误:未发现的资源匹配给定名称:ATTR机器人:actionModeShareDrawable。
 

解决方案

您需要做的唯一的事情就是打开 Android的支持-V7-appcompat的 project.properties 文件并改变从目标=机器人-19 目标目标=机器人-21
后来才做了项目 - &GT;清洁... ,以使更改生效。


的IntelliJ IDEA(不使用摇篮)

类同的Eclipse是不够的,只使用了 Android的支持-V7-appcompat.jar ;你必须导入 appcompat 作为一个模块。了解更多关于它的这个<一href="http://stackoverflow.com/questions/18025942/how-do-i-add-a-library-android-support-v7-appcompat-in-intellij-idea">StackO-Post (点击)。
注意: 如果你只使用了的.jar 你会得到 NoClassDefFoundErrors 上运行的)

当你试图建立你面对的 RES /值-V ** 文件夹的问题的项目。您的留言窗口会说一些这样的:

 错误:Android的容易编译:[appcompat]资源发现,匹配给定的名字:ATTR机器人:colorPrimary。
错误:(75,-1)的Andr​​oid容易编译:[appcompat] C:\ [你的路径] \ SDK \演员\机器人\ SUPPORT \ V7 \ appcompat \水库\值-V21 \ styles_bas​​e.xml:75:错误:没有资源的发现,匹配给定的名字'机器人:Widget.Material.ActionButton错误检索父项。
// 等等
 

解决方案

右键点击 appcompat 模块 - >打开模块设置(F4) - > [Dependency选项卡] 的选择Android的API从21平台下拉菜单 - >应用

然后,只需重建项目(建设 - >重建项目),你是好去。

When attempting to use the latest appcompat-v7 support library in my project, I get the following error:

/Users/greg/dev/mobile/android_project/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'.

How do I fix this?

解决方案

While the answer of loeschg is absolutely correct I just wanna elaborate on it and give a solution for all IDE's (Eclipse, IntellJ and Android Studio) even if the errors differentiate slightly.


Prerequirements

Make sure that you've downloaded the latest extras as well as the Android 5.0 SDK via the SDK-Manager.


Android Studio

Open the build.gradle file of your app-module and change your compileSdkVersion to 21. It's basically not necessary to change the targetSdkVersion SDK-Version to 21 but it's recommended since you should always target the latest android Build-Version.
In the end you gradle-file will look like this:

android {
    compileSdkVersion 21
    // ...

    defaultConfig {
        // ...
        targetSdkVersion 21
    }
}

Be sure to sync your project afterwards.


Eclipse

When using the v7-appcompat in Eclipse you have to use it as a library project. It isn't enough to just copy the *.jar to your /libs folder. Please read this (click) step-by-step tutorial on developer.android.com in order to know how to import the project properly.

As soon as the project is imported, you'll realize that some folders in the /resfolder are red-underlined because of errors such as the following:

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:Widget.Material.*'
error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.

Solution

The only thing you have to do is to open the project.properties file of the android-support-v7-appcompat and change the target from target=android-19 to target=android-21.
Afterwards just do a Project --> Clean... so that the changes take effect.


IntelliJ IDEA (not using Gradle)

Similiar to Eclipse it's not enough to use only the android-support-v7-appcompat.jar; you have to import the appcompat as a module. Read more about it on this StackO-Post (click).
(Note: If you're only using the .jar you'll get NoClassDefFoundErrors on Runtime)

When you're trying to build the project you'll face issues in the res/values-v** folders. Your message window will say something like the following:

Error:android-apt-compiler: [appcompat]  resource found that matches the given name: attr 'android:colorPrimary'.
Error:(75, -1) android-apt-compiler: [appcompat] C:\[Your Path]\sdk\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:75: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
// and so on

Solution

Right click on appcompat module --> Open Module Settings (F4) --> [Dependency Tab] Select Android API 21 Platform from the dropdown --> Apply

Then just rebuild the project (Build --> Rebuild Project) and you're good to go.

这篇关于appcompat-V7:21.0.0“:没有资源的发现,匹配给定的名字:ATTR”机器人:actionModeShareDrawable“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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