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

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

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

Android application error in eclipse

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

Error: String types not allowed (at 'screenOrientation' with value 'sensorPortait')

I imported android project an I got 3 errors
error: Error: String types not allowed (at 'screenOrientation' with value 'sensorPortait'). AndroidManifest.xml /com.cartmillimaging.fishingmate.MapViewActivity line 16 Android AAPT Problem
same error on different lines.
<activity android:name=".MapViewActivity" android:screenOrientation="sensorPortait">
For project build target I have selected Google APIs 2.3.3. 10.
I also enabled Java compiler project specific settings and put compiler compliance error to 1.6.
I am new to android development, so can you help me?
checkout your API level. The following attributes:
android:screenOrientation="sensorPortrait" only can work on API level 16+
android:screenOrientation="sensorPortait" can work under level 15
I think it's a fixed bug
There's a typo error in the value. The correct name is "sensorPortrait"
when you load project I get this error (I use api level 10). I found solution for this. You change screenOrientation to something else, save it, and then return to sensorPortait and everything now is working.
Confirmed what cashmere said.
i changed all
android:screenOrientation="sensorPortrait"
to
android:screenOrientation="sensorLandscape"
built the project and then changed it back again for all my activites in the manifest and all works good :)
Had this error and couldn't kick it. Some how my build settings had API 13 selected... Selected API 21 and yay no more issue!

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

android - how can i use the "android:layoutDirection"?

it seems that android 4 provides "android:layoutDirection" for linearLayout and "android:textDirection" for textView , but when i choose them , i get a compilation error that it doesn't recognize them like that:
error: No resource identifier found for attribute 'layoutDirection' in package 'android'
i also can't find out more information on the internet about those attributes. what do they mean, and how come i can't use them?
It works if you change your project properties to API Level 17.
May be help u.
Note: To enable right-to-left layout features for your app, you must set supportsRtl to "true" and set targetSdkVersion to 17 or higher.
http://developer.android.com/guide/topics/resources/providing-resources.html#table2

Categories

Resources