appcompat-v7:21.0.0': No resource found that matches the given name: attr 'android:actionModeShareDrawable'
Solution 1
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 /res
folder 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.
Solution 2
This is likely because you haven't set your compileSdkVersion
to 21 in your build.gradle file. You also probably want to change your targetSdkVersion
to 21.
android {
//...
compileSdkVersion 21
defaultConfig {
targetSdkVersion 21
}
//...
}
This requires you to have downloaded the latest SDK updates to begin with.
Once you've downloaded all the updates (don't forget to also update the Android Support Library/Repository, too!) and updated your compileSdkVersion, re-sync your Gradle project.
Edit: For Eclipse or general IntelliJ users
See reVerse's answer. He has a very thorough walk through!
Solution 3
`Follow below steps:
its working for me.To resolve this issue,
1.Right Click on appcompat_v7 library and select Properties
2.Now, Click on Android Option, Set Project Build Path as Android 5.0 (API level 21) Apply Changes.
3.Now go to project.properties file under appcompat_v7 library,
4.Set the project target as : target=android-21
5.Now Clean + Build appcompat_v7 library and your projects`
Solution 4
In case you don't want to use API 21 as the target API, and thus you don' t want to use the Material Theme, you have to use an older revision belonging to API 19 >
compile "com.android.support:appcompat-v7:19.0.+"
This also helps solving your problem, it only depends on what you want to achieve.
Solution 5
I have encountered this issue with play-services:5.0.89. Upgrading to 6.1.11 solved problem.
![loeschg](https://i.stack.imgur.com/VxL0m.jpg?s=256&g=1)
loeschg
Updated on July 12, 2022Comments
-
loeschg almost 2 years
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?
-
sbaar over 9 yearsThis is the correct answer. Upgrading to 21 requires this, the new appcompat dependencies, and you need to download rev 12 of play services.
-
Chad Bingham over 9 yearsAnd be sure to run JDK 7
-
prabhakaran over 9 yearsi am also facing same prob in eclipse after change the target from target=android-19 to target=android-21 also getting error on value folder dude
-
reVerse over 9 yearsThat's surprising. Did you clean & rebuild the project? Maybe you should import the project once again.
-
Clive Jefferies over 9 yearsWhen I change AppCompat to 5.0 in eclipse, it no longer builds and the .bin folder is empty.
-
ChuongPham over 9 yearsCleaning your project in this case does not work, especially if you've just downloaded a new Android SDK, appcompat library, etc., as errors won't magically clean themselves without finding the missing links to other Android libraries and/or resources. ReVerse's answer is correct and most thorough for those who do not know how to resolve issues with the latest Android API level 21 download by themselves.
-
loeschg over 9 years0.14.0 was actually released not too long ago
-
avianey over 9 yearsyep, I was still using 0.12... maybe it can help someone else upgrading to 0.13 or 0.14
-
loeschg over 9 yearsWhile still correct, see @reVerse's solution. It's more thorough :)
-
KarenAnne over 9 yearsI was using Eclipse ADT and changing the target from Android 19 to 21 did the trick! Thanks!
-
Mukesh Garg over 9 yearsAwesome, really i was struggling from past 2 days, but ur trick change Android-19 to 21 worked.. Thanks Man
-
Md Mohsin over 9 yearsI used your way and set android-21 target in project and library and then clean both and done..thanks.
-
Bianca Daniciuc over 9 yearsUsing Eclipse, I had to update the project target to 21 on all projects that were using the appcompat library, not only on the appcompat project itself.
-
reubenjohn over 9 yearsGreat answer! I was missing the "Google repository" in the SDK manager, which caused an
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Base.AppCompat.DialogWhenLarge.Base'.
-
SleepNot over 9 yearswhere can I find the appcompat_v7 library?
-
madhu527 over 9 yearsyou can find appcompat_v7 lib in : adt-bundle-windows-x86_64 -->sdk -->\extras\ -->android\ -->support -->v7
-
peacepassion over 9 yearsI agree with you. After all, not everyone plans to target sdk at 21.
-
Pankaj Nimgade over 9 years@reVerse, iam still getting Cannot resolve symbol 'android:Theme.Material.Light' in <style name="AppBaseTheme" parent="android:Theme.Material.Light"></style> in valules-v21 in android studio
-
Michael Todd about 9 yearsThis answer in combination with loeschg's answer above resolved this issue in Eclipse.
-
Antwan over 8 yearsi was using a latest version from appcompact but now i want to doengrade to earlier version but i'm getting this error in exploded-arr folder
-
Amt87 over 8 yearsThat is great answer. just a note, I had to modify the target to be android-# with the latest android api level that I installed on my sdk
-
afterxleep about 8 yearsI am currently wrestling with the previous issues mentioned in eclipse / android. It really is a load of unreliable impenetrable bollocks.
-
Eugene Gr. Philippov about 8 yearsI executed your sequence. Then had a «Jar mismatch! Fix your dependencies» in the Android console because jars in libs/ and jars in dependent appcompat and google play services library projects were not matching (were having mismatching SHA-1 and jar file length). Struggling further, I consider this a success.
-
nette almost 8 yearsThanks! This was so helpful. I had to change mine to 23 though.
-
Valen almost 8 yearsdidn't use neither one of the IDEs nor Gradle... is it similar when I use Ant and Notepad?