Build errors with action bar, support library - android

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

Related

Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.....'

I receive these errors when I try to add Facebook in app notification library
compile 'com.facebook.android:notifications:1.0.2'
Error:(33) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(33) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
compile sdk version is 22 , build Tools Version is 23.0.2.
push notifications libray - https://github.com/facebook/FBNotifications
I know if I change compile sdk version to 23 this error will go away. but on my project I using some methods that were deprecated on version 23 its not possible at the moment to change compile sdk version to 23.
Is there any other method to make this error go away
There's no solution other than to change your compile SDK version to 23 or not use that library. If a library is built against a higher SDK (and requires new APIs from that SDK), then your app must also build against the higher SDK.
Per the Picking your compileSdkVersion blog post:
It should be emphasized that changing your compileSdkVersion does not change runtime behavior. While new compiler warnings/errors may be present when changing your compileSdkVersion, your compileSdkVersion is not included in your APK: it is purely used at compile time.
It is targetSdkVersion that potentially changes the behavior of your app is what you should make sure to test before incrementing.

Is there any recommended compileSdkVersion for each Google Play Services SDK version?

As the topic suggested, as I try to update the version of Google Play Services SDK used in my app (from 5.0.89 to 9.2.0):
compile 'com.google.android.gms:play-services:9.2.0'
A large batch of errors like the one below occur:
> .../app/build/intermediates/res/merged/debug/values-v21/values-v21.xml
>
> Error:(13) Error retrieving parent for item: No resource found that
> matches the given name 'android:TextAppearance.Material.Inverse'.
>
> Error:(15) Error retrieving parent for item: No resource found that
> matches the given name
> 'android:TextAppearance.Material.Large.Inverse'.
>
> ...
And:
> .../com.android.support/appcompat-v7/23.0.0/res/values-v21/values-v21.xml
>
> Error:(82, 5) No resource found that matches the given name: attr
> 'android:colorAccent'.
> Error:(82, 5) No resource found that matches the given name: attr 'android:colorButtonNormal'.
> ...
Which I happens to fix them by raising the compileSdkVersion of my project. Then I tried to selectively compile only the SDKs I needed in my project, i.e.:
compile 'com.google.android.gms:play-services-gcm:9.2.0'
compile 'com.google.android.gms:play-services-analytics:9.2.0'
compile 'com.google.android.gms:play-services-ads:9.2.0'
With this setting I was able to keep my original compileSdkVersion, which is 19, and build and (seem to?) run the application without problem.
However, this left me wondering if there will be any potential problem as there is such a significant update regarding those SDKs. And this raised the question as suggested in the topic.
Per the Picking your compileSdkVersion, minSdkVerison, and targetSdkVersion blog post:
It should be emphasized that changing your compileSdkVersion does not change runtime behavior.
Therefore it is strongly recommended that you always compile with the latest SDK. You’ll get all the benefits of new compilation checks on existing code, avoid newly deprecated APIs, and be ready to use new APIs.
Note that if you use the Support Library, compiling with the latest SDK is a requirement for using the latest Support Library releases. For example, to use the 23.1.1 Support Library, you must have a compileSdkVersion of at least 23 (those first numbers need to match!).
So just always use the latest version for compileSdkVersion

Android No resource found that matches given name Error

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!

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
}

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"/>

Categories

Resources