378

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?

Jon Douglas
  • 12,601
  • 4
  • 36
  • 50
loeschg
  • 28,353
  • 25
  • 89
  • 143
  • 1
    I'm getting this issue in eclipse. I had over a 100 errors because my SDK Build tools did not update to rev 21. Got different errors now though so... go to look into those. – RED_ Oct 17 '14 at 20:16
  • Today I uninstalled and reinstalled Extras/Android Support Library (version 21.0.2) and note that its project.properties *still* incorrectly point to target=android-19 which is the root of the problem. Should be 21, but it's a generated - not hand-editable - file. See accepted answer for workaround. – JulianSymes Nov 26 '14 at 12:54
  • @RED_, Cannot resolve symbol 'android:Theme.Material.Light' in in valules-v21 in android studio – Pankaj Nimgade Mar 05 '15 at 10:55
  • @PankajNimgade I don't understand... do you need help? – RED_ Mar 06 '15 at 01:41
  • @RED_, yes i do need help desperately, on my computer I can't seem to detect anything for Material Theme or anything which starts with android in values-v21\styles, kindly help me – Pankaj Nimgade Mar 06 '15 at 04:30
  • @PankajNimgade You should search SO or open a new question. – RED_ Mar 13 '15 at 11:38

14 Answers14

598

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.

Picture of 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.

Android Studio Gradle Sync reminder


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:

Errors in Eclipse

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

Select API 21 Platform

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

Community
  • 1
  • 1
reVerse
  • 33,862
  • 21
  • 85
  • 82
  • 2
    i 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 – prabhakaran Oct 21 '14 at 06:04
  • That's surprising. Did you clean & rebuild the project? Maybe you should import the project once again. – reVerse Oct 21 '14 at 07:16
  • 1
    When I change AppCompat to 5.0 in eclipse, it no longer builds and the .bin folder is empty. – Clive Jefferies Oct 22 '14 at 13:03
  • I was using Eclipse ADT and changing the target from Android 19 to 21 did the trick! Thanks! – KarenAnne Nov 13 '14 at 10:01
  • 1
    Awesome, really i was struggling from past 2 days, but ur trick change Android-19 to 21 worked.. Thanks Man – Mukesh Garg Nov 24 '14 at 08:17
  • 1
    Using 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. – Bianca Daniciuc Dec 18 '14 at 16:23
  • Great 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'.` – reubenjohn Jan 18 '15 at 18:32
  • @reVerse, iam still getting Cannot resolve symbol 'android:Theme.Material.Light' in in valules-v21 in android studio – Pankaj Nimgade Mar 05 '15 at 11:01
  • That 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 – Amt87 Jan 12 '16 at 21:27
  • 1
    I am currently wrestling with the previous issues mentioned in eclipse / android. It really is a load of unreliable impenetrable bollocks. – AndyUK May 02 '16 at 00:00
  • Thanks! This was so helpful. I had to change mine to 23 though. – nette Jul 11 '16 at 06:14
123

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.

Android Studio SDK Manager

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!

loeschg
  • 28,353
  • 25
  • 89
  • 143
22

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

madhu527
  • 4,226
  • 1
  • 25
  • 27
12

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.

vandus
  • 2,968
  • 3
  • 26
  • 42
9

I have encountered this issue with play-services:5.0.89. Upgrading to 6.1.11 solved problem.

pepyakin
  • 2,045
  • 16
  • 29
8

In Android Studio I was trying to set the compileSdkVersion and targetSdkVersion to 19.

My solution was to replace at the bottom of build.gradle, from this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

To the older version of the appcompat library:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.+'
}
Gianfranco P.
  • 6,858
  • 3
  • 40
  • 56
  • i 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 – Antwan Oct 15 '15 at 02:08
3

I had added another project to my workspace and was trying to reference an activity from it in the manifest file, and I was getting this error. The problem is I was referencing the library incorrectly. This is how I fixed the problem:

  • Right click on project
  • Select Properties
  • Click on Android on left menu
  • Click on Add
  • Please select a Library Project

The jar went into Android Dependencies folder and this error was fixed.

live-love
  • 34,372
  • 16
  • 163
  • 152
  • I 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. – Eugene Gr. Philippov Jul 03 '16 at 23:47
2

Make sure you clean your project in android studio (or eclipse),

It should solve your issues

Brendon Sled
  • 118
  • 3
  • 2
    Cleaning 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. – ChuongPham Oct 23 '14 at 16:05
2

Upgrading to latest gradle plugin solve my problem :

classpath 'com.android.tools.build:gradle:0.13.+'
avianey
  • 4,913
  • 3
  • 24
  • 53
2

After creating a second project in the workspace in eclipse, I had this problem. I believe it is because I created it with a different SDK version and this ovewrote the android-support-v7-appcompat library.

I tried to clean everything up but to no avail. Ultimately, the suggestion above to edit project.properties and change target=android-21 and set my project to Android 5.0, fixed it.

formica
  • 864
  • 1
  • 8
  • 16
2

What I recomend is: (This works to me after many days with errors)

-Make sure that you have downloaded:

- the Lastest SDK Platform from the latest Android version
- Android Suppor Librarie and Repository from EXTRAS 

-Redowload the ADT

-Make a security copy of your project.

-You must have the ADT, the workspace and the project that we will import in the same disk (e.g. C:/)

  1. Now delete the app compat and your project.

  2. In eclipse: File > Import > Android existing project > Next > Browse (The folder where you have your ADT)/sdk/extras/android/v7/appcompat > Import > Finish

  3. Now in the eclipse Package Explorer: android-support-v7-appcompat/libs/ Make on the two JARS: Right click > Build Path > Add to Build Path

  4. Right click on libs/ folder > Buil Path > Configure Build Path and check this two JARS > OK

  5. On the upper eclipse bar > Project > Clean

  6. Import your project > File > Import > Browse your project > Finish

  7. Now, Right click on the projectfile and android-support-v7-appcompat > Properties > Android > And select the latest API that appears > OK

  8. Right click on the projectfile > Properties > Android > Add > android-support-v7-appcompat

  9. On the upper eclipse bar > Project > Clean

juldeh
  • 109
  • 11
2

I got the same error when I changed the Compile SDK version from API:21 to API:16. The problem was, appcompat version. If you need to use an older version of android API, so you have to change this appcompat version also. In my case (for API:16), I had to use appcompat-v7:19.+.

So I replace dependencies in build.gradle as follows,

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.+'
}

And make sure you have older versions of appcompat versions on your SDK enter image description here

mili
  • 2,464
  • 1
  • 23
  • 22
2

I was up to date with everything and still got this error, not sure why but I think the image was corrupted in a strange way and after replacing the image I got rid of the error. Might be worth to try with a different image :)

DoruChidean
  • 6,811
  • 1
  • 25
  • 31
1

My problem was that I had other libraries that my project referenced and those libraries had another version of appcompat referenced. This is what I did to resolve the issue:

(You should back up your project before doing this)

1) I deleted all the appcompat layout folders (ex: /res/layout-v11).

2) Solved the problems that arose from that, usually an error in menu.xml

3) Back to main project and add appcompat library, clean, and everything works!

tricknology
  • 933
  • 1
  • 14
  • 26