Android No resource found that matches given name Error - android

I have set my app's min Sdk version to jelly bean. (created for kit kat)
after that this error occurred.
Android Studio : No resource found that matches the given name: attr 'android:actionModeShareDrawable'
how can I solve this ?

From Error
No resource found that matches the given name: attr 'android:actionModeShareDrawable'
The issue is about compling application with lower target.
AppCompat v21 builds themes that require the new APIs provided in API 21 (Android 5.0). To compile your application with AppCompat, you must also compile against API 21. The recommended setup for compiling/building with API 21 is a compileSdkVersion of 21 and a buildToolsVersion of 21.0.1 (which is the highest at this time - you always want to use the latest build tools).
Make sure the value for target (which tells the target android version) in project.properties file of both your project folder and appcompat_v7 folder is same
: inside 'your_project'/project.properties
target=android-21
android.library.reference.1=../appcompat_v7
and
: inside appcompat_v7/project.properties
target=android-21
android.library=true
and after this don't forget to clean your project .
Hope it helps!

Related

Android support libraries, compile SDK version and minimum SDK version

I have some general questions about the use of support libraries but I can't find good resources to answer them.
Context :
The app I'm working on has a minimum SDK target set to 9. I'm working with support libraries v4 and v7 that I import with gradle using
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
I also declare the version of sdk to compile against and the minimum SDK version with
minSdkVersion 9
compileSdkVersion 22
Now this will compile and build an apk without error. But when I change the compileSDKVersion to 19, I will get a lot of errors such as
Error:(2) Error retrieving parent for item: No resource found that
matches the given name 'android:TextAppearance.Material.Inverse'.
telling me that the SDK I'm compiling with does not contain some resources used by the compatibility libraries, I should instead use previous compatibility libraries.
Questions:
What is the minimum SDK version I can compile against using both v4 and v7 (or what is the minimal SDK version supported by both v4 and v7) ? Is there a way to see all the versions available in the Android Support Repository ?
Is it risky to set the minimum SDK version to 9 and the compileSDKVersion to 22 and use elements provided by the Support library targetting API 22? I mean: may I get runtime exception due to missing classes/resources ?
Is there a way to configure Gradle to show some potential incompatibilities ? I know sometimes I get a compiling error when using methods present in higher API than the minimum one. But does it generalize to xml as well (such as themes or resources) ?
I know that I get compiling errors when a (support) library references a resource that is not present in the compiled SDK. Is there a way to get similar warnings/errors for the minimum SDK as well ?
Sorry if the questions are too vague, let me know if you need some precisions ! If you know interesting resources that might answer part of a question, don't hesitate to share here ;)
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
It happens because the support libraries v22 require API 22.
You can't compile with API 19.
What is the minimum SDK version I can compile against using both v4 and v7 (or what is the minimal SDK version supported by both v4 and v7)
Usually the minSdk is in the name of the library.
It is api4 for the v4 and api7 for the appcompat.
Is there a way to see all the versions available in the Android Support Repository ?
You can check it inside the folder androidsdk\extras\android\m2repository\com\android\support opening the aar file for example.
Is it risky to set the minimum SDK version to 9 and the compileSDKVersion to 22 and use elements provided by the Support library targetting API 22? I mean: may I get runtime exception due to missing classes/resources ?
No if you are using the support libraries v22.
I know that I get compiling errors when a (support) library references a resource that is not present in the compiled SDK. Is there a way to get similar warnings/errors for the minimum SDK as well ?
No for my experience.
There is a general rule.
The library major version number is the minimun compile sdk version.
It means:
support libraries v21.x.x -> requires API 21
support libraries v22.x.x -> requires API 22
support libraries v23.x.x -> requires API 23

Missing styles from android appcompat v7-21.0.0

I originally was using compile 'com.android.support:appcompat-v7:19.0.1', and I decided to implement a DrawerLayout. Unfortunately, I was informed that the v4 support library's ActionBarDrawerToggle is deprecated, and to use the v7 version. It appears that this isn't in the 19.0.1 version of support-v7-appcompat, so I decided to upgrade to compile 'com.android.support:appcompat-v7:21.0.0'. Now, however, I'm getting the following error in my styles:
Error:Error retrieving parent for item: No resource found that matches the given name '#style/Widget.AppCompat.Light.Base.ActionBar.TabBar.Inverse'.
(There are a few others).
I've tried a few things, including the following:
Error in styles_base.xml file - android app - No resource found that matches the given name 'android:Widget.Material.ActionButton'
Error retrieving parent for item: No resource found that matches the given name '#android:style/TextAppearance.Holo.Widget.ActionBar.Title'
My build.gradle has the following configuration:
defaultConfig {
minSdkVersion 11
targetSdkVersion 17
}
The v4 support library's ActionBarDrawerToggle was deprecated with the support library v21.
The v7 version was introduced with the appCompat library v21.
Also if you are using the appCompat library v21 you have to compile with API 21+.
Change your build.gradle file:
android {
compileSdkVersion 21
defaultConfig {
minSdkVersion 11
targetSdkVersion 21
}

Build errors with action bar, support library

I get many compilation errors when trying to add an ActionBar to my app. Any help is much appreciated!
I recently moved my application development from Eclipse to Android Studio. I'm an absolute novice wrt Android Studio and gradle. I want to add an ActionBar to my app. I want to support devices running at least API level 9. Per the Android developer doc, I see that I've got to use the V7 appcompat library. My SDK manager indicates that both Android Support Repository rev 11 and Android Support Library rev 21.0.3 have been installed. I've also read that my project should use both support-v4 as well as appcompat-v7 - is that right? The gradle file for my app module contains this:
defaultConfig {
applicationId "com.tomoreilly.solarisalpha"
minSdkVersion 9
targetSdkVersion 9
}
[...]
dependencies {
compile project(':androidLVL')
compile 'com.google.android.gms:play-services:+'
compile files('libs/acra-4.2.3.jar')
compile files('libs/htmllexer.jar')
compile "com.android.support:appcompat-v7:21.0.3"
compile 'com.android.support:support-v4:13.0.0'
}
Not sure what version numbers to use for the libraries. I specify appcompat-v7:21.0.3 because SDK manager indicates Android Support Library rev 21.0.3. But what about the version number for support-v4? I just got "13.0.0" from an example on the internet, because support-v4 doesn't seem to show in my SDK manager at all.
When I try to build my project I get many errors like these:
Error:(6, 21) No resource found that matches the given name: attr 'android:actionModeCopyDrawable'.
Error:(5, 21) No resource found that matches the given name: attr 'android:actionModeCutDrawable'.
Error:(7, 21) No resource found that matches the given name: attr 'android:actionModePasteDrawable'.
Error:(8, 21) No resource found that matches the given name: attr 'android:actionModeSelectAllDrawable'.
Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Can someone see what I am missing or doing wrong?
Thanks!
Tom
appcompat-v7 automatically includes support-v4, so you can remove that line entirely.
Also make sure your compileSdkVersion in your build.gradle is set to 21 as well as per this question

Error retrieving parent for item: No resource found that matches the given name

may be it is the problem of minimum SDK but don't know how to solve it so kindly help me
[2014-10-26 00:54:30 - asa] C:\Users\Ahsan\appcompat_v7\res\values-v21\styles_base.xml:69: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Subtitle'.
[2014-10-26 00:54:30 - asa]
Stackoverflow answering the same question: Here
Accepted answer from the question:
Turns out that I had to make the target and compile version to L which
meant that I could not run my app on older SDKs. If you want your app
to run on SDK 19 and lower you have to set your compile and target
version to 19 and your min SDK to whatever version you need.
Next you have to adjust your imports to the version that is compatible
with the SDKs that you have chosen to compile for. For example if you
want to use the v7 support library on sdk 19 you must import it like
this: compile compile 'com.android.support:appcompat-v7:20.+'
So yes, it is an issue with minimum SDK, I would recommend that you raise your minimum SDK to one that supports this.
To raise or change your minimum SDK, change the following code in your AndroidManifest.xml
<uses-sdk android:minSdkVersion="x"/>

appcompat-v7:21.0.0': No resource found that matches the given name: attr 'android:actionModeShareDrawable'

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 or build.gradle.kts 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.
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!
`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`
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.
I have encountered this issue with play-services:5.0.89. Upgrading to 6.1.11 solved problem.
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.+'
}
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.
Make sure you clean your project in android studio (or eclipse),
It should solve your issues
Upgrading to latest gradle plugin solve my problem :
classpath 'com.android.tools.build:gradle:0.13.+'
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.
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:/)
Now delete the app compat and your project.
In eclipse: File > Import > Android existing project > Next > Browse (The folder where you have your ADT)/sdk/extras/android/v7/appcompat > Import > Finish
Now in the eclipse Package Explorer: android-support-v7-appcompat/libs/ Make on the two JARS: Right click > Build Path > Add to Build Path
Right click on libs/ folder > Buil Path > Configure Build Path and check this two JARS > OK
On the upper eclipse bar > Project > Clean
Import your project > File > Import > Browse your project > Finish
Now, Right click on the projectfile and android-support-v7-appcompat > Properties > Android > And select the latest API that appears > OK
Right click on the projectfile > Properties > Android > Add > android-support-v7-appcompat
On the upper eclipse bar > Project > Clean
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
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 :)
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!

Categories

Resources