Android application error in eclipse - android

Whenever i run the code as an application in my Eclipse it shows an error:
\workspace\appcompat_v7\res\values-v21\themes_base.xml:150: error: Error: No resource found that matches the given name: attr 'android:windowElevation'.
But the example files runs. How to rectify it?

Make sure your appcompat_v7 targeting Android 5.0 or later.

First check your minApi:
Notice that android:windowElevation works for API > 20
If your API is right:
make sure you have installed Android 5.0 SDK via the SDK-Manager
For pre-lollipop devices check this

change this line in your style.xml file
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
to :
<style name="AppBaseTheme" parent="android:Theme.Light">

Related

AAPT: error: invalid resource type 'attr' for parent of style, after updating gradle

After upgrading from Gradle wrapper 4.4.1 to 6.1.1, along with going from Android build tools 2.3.0 to 4.0.0, builds all of a sudden fail with the following error:
res/values/treeview_styles.xml:3:5-6:13: AAPT: error: invalid resource type 'attr' for parent of style.
The resource file in question looks like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style parent="#android:attr/listViewStyle" name="treeViewListStyle">
<item name="android:background">#android:color/white</item>
<item name="android:divider">#drawable/divider</item>
</style>
</resources>
What is happening here, and how can I fix this?
Background information: The code comes from a tree list view control I am using in my app. I have simply copied the source tree into mine so that I could make some modifications.
The developer reference for android.R.attr mentions listViewStyle, stating it has been available since API 1, so I am wondering if it is a reference to that. On the other hand, my app uses appcompat-v7, and in my local SDK tree at extras/android/support/v7/appcompat/res/values/themes_base.xml I indeed found:
<style name="Base.Theme.AppCompat.CompactMenu" parent="">
<item name="android:itemTextAppearance">?android:attr/textAppearanceMedium</item>
<item name="android:listViewStyle">#style/Widget.AppCompat.ListView.Menu</item>
<item name="android:windowAnimationStyle">#style/Animation.AppCompat.DropDownUp</item>
</style>
That looks as if android:listViewStyle is just an alias for #style/Widget.AppCompat.ListView.Menu. Indeed, using #style/Widget.AppCompat.ListView.Menu compiles and the UI looks OK at first glance.
Note that the toolchain upgrade included switching from AAPT to AAPT2. According to this question and its answers, AAPT2 is stricter about some things than its predecessor. In particular, parents of styles must be styles as well. That would at least explain the error message, we just need to hunt down the correct resource name.
ianhanniballake wrote:
The problem is parent="#android:attr/listViewStyle", so replacing that with an actual parent theme, and not something from an attribute, would indeed fix it. What theme are you using?
In addition i found that:
Behavior changes when using AAPT2:
Additionally, when declaring a element, its parent must also
be a style resource type. Otherwise, you get an error similar to the
following:
Error: (...) invalid resource type 'attr' for parent of style

Faced with Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'

I am stuck with a problem, I have created a basic hello world app following official website! now when I try running the app I see error as
error:
Error retrieving parent for item: No resource found that matches the given name '
Theme.AppCompat.Light.DarkActionBar'.
Resourse: styles.xml
path: /Test_1/res/values-v14
Location : line 8
Type: Android AAPT Problem
I tried adding v7 library by [Project ->Properties->Android] and click on "Add" but I do not see any thing in the resulted project Selection pop up. I see error in (appcompat-v7 ->res->values-large-v14->themes_base.xml
code:
<style name="Theme.Base.AppCompat.DialogWhenLarge"
parent="Theme.Base.AppCompat.DialogWhenLarge.Base" />
<style name="Theme.Base.AppCompat.Light.DialogWhenLarge"
parent="Theme.Base.AppCompat.Light.DialogWhenLarge.Base" />
My target sdk is API 19 and min sdk version is 7, I am not sure how to deal with this. could you please help.
It looks like all Theme.Base.xxxx was renamed to Base.Theme.xxxx
Try to use Base.Theme.AppCompat.DialogWhenLarge

unprefixed attribute is giving error in style.xml

I am using actionbar sherlock for compatibility with android version >= 8
and while using the code it gives me error
error: Error: No resource found that matches the given name: attr 'titleTextStyle'.
my code used in the xml is
<style name="MyTheme.ActionBarStyle" parent="#style/Widget.Sherlock.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
You have to change the build SDK to at least API 11 (Honeycomb).
I have experiment this issue too with AndroidSherlock ActionBar. EveryTime I change something inside style I get those erros to. Closing the the style file and clean -> rebuild fix tipically for me

Can't reference Holo theme from values-v11/themes.xml

I'm trying to make my app use the Holo Light theme if it is running on a 3.0+ device, but for some reason the values-v11 method isn't working. I see a bunch of other people apparently using this method, but when I define my theme in res/values-v11/themes.xml:
<resources>
<style name="MainStyle" parent="#android:Theme.Holo.Light">
</style>
</resources>
Eclipse gives me error: Error retrieving parent for item: No resource found that matches the given name '#android:Theme.Holo.Light'. It's the same whether I use android:Theme.Holo.Light or android:style/Theme.Holo.Light.
My minSdkVersion is set to 10 and my targetSdkVersion is set to 15.
Any ideas?
I suspect you should be using parent="#android:style/Theme.Holo.Light". Make sure it's exactly like this--with the # sign and everything.
From comments: Also make sure you've set your target API (different from the target SDK) in the Project Properties (not the manifest) to be at least 4.0/API 14.
Set your Project Build Target above or equal to 14 and make sure you used correct syntax for Theme.Holo.Light.
It should be like this
parent="#android:style/Theme.Holo.Light"
TextAppearance.Holo.Widget.ActionBar.Title appears to have been added in API Level 13. Make sure your build target is set to 13, not just 11.
AndroidManifest.xml:
<uses-sdk
android:minSdkVersion=...
android:targetSdkVersion="11" />

Error in changing the android API level?

when i am creating new project i added API level 14 , i have completed my application and i want to change the API level to 10 ,
i am getting and error in resources-->values-v11--> style.xml
i.e error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.
in resources-->values-v14--> style.xml
i.e error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar'.
i dint understood this can any one explain
Following ankita gahoi's advice, I searched a little further and solved the problem.
Try this:
Delete the folders 'values-11' and 'values-14' (if any of them exist). Then, if this error shows up in the console window:
"No resource identifier found for attribute 'showAsAction' in package 'android'"
Read the answers to these questions:
"No resource identifier found for attribute 'showAsAction' in package 'android'" (Jason Hanley's)
How to change target build on Android project? (Alan Will's)
My build target was already set to the right Android version, so I set it to 'Google APIs' and then back to the former target.
These themes are available in API level 11 or higher so it will not work.because you are using API level 10.
refer this link-
http://developer.android.com/guide/topics/ui/themes.html
Happened to me on a specific case where one of the Android Library Projects had its reference SDK set to API 9. What got me confused was that the Error Log showed the name of the project with the correct settings, and not the problematic one.
go to values-v11--> style.xml. replace code :
<style name="LightThemeSelector" parent="android:Theme.Light">
by code :
<style name="LightThemeSelector" parent="android:Theme.Light">

Categories

Resources