unprefixed attribute is giving error in style.xml - android

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

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 ListView style - cycles in resource definitions

This code
<style name="listViewPrefs" parent="#android:Widget.ListView">
...
</style>
produces the following Android Rescources Validation error:
Invalid parent reference: expected #style. There should be no cycles in
resource definitions as this can lead to runtime exceptions.
How can this be fixed?
I think you have to use like,
<style name="listViewPrefs" parent="#android:style/Widget.ListView">
...
</style>

Error: style attribute '#android:attr/windowExitAnimation' not found

I recently upgraded to the gradle-3.0.0-alpha8 after which some styles are not resolved at compile time.
Develop envirment:
IDE: Android studio 3.0 Bate3
Gradle build tools : 'com.android.tools.build:gradle:3.0.0-beta3'
Gradle :gradle-4.1-all.zip
Error info:
Error:(94, 5) style attribute '#android:attr/windowExitAnimation' not found
Error:(94, 5) style attribute '#android:attr/windowEnterAnimation' not found
Setting android.enableAapt2=false in gradle.properties file can solve this isuue.
But, Instant App need android.enableAapt2=true. What would i do?
All the problem was solved already.
Cause of the problem:
There are two modules, A_module, B_module.
B_module has a style:
<style name="my_style”>
<item
name="#android:windowEnterAnimation">#anim/anim_toast_show</item>
<item
name="#android:windowExitAnimation">#anim/anim_toast_hide</item>
</style>
If B_module compile(':A_module')
Build or Clean, report a error location in A_module->Res->values->styles:
Error:(94, 5) style attribute '#android:attr/windowExitAnimation' not found
Error:(94, 5) style attribute '#android:attr/windowEnterAnimation' not found
Solution:
Removing the "#" at the start of the item name.
<item name="#android:windowEnterAnimation">#anim/anim_toast_show</item>
<item name="#android:windowExitAnimation">#anim/anim_toast_hide</item>
to:
<item name="android:windowEnterAnimation">#anim/anim_toast_show</item>
<item name="android:windowExitAnimation">#anim/anim_toast_hide</item>
Setting android.enableAapt2=false in the gradle.properties file fixes this issue. See the Stack Overflow question I linked.
It will help you!
Removing a custom attribute
I got a similar error when I deleted an attribute for a custom view. The reason the error came up was that I still had xml references to it in my project.
Pressing Ctrl + Shift + F to search the entire project for the offending attribute and then removing all references to it solved the problem.

Unable to compile Android app with Sherloc theme

Sorry to trouble i have been trying to fix these issues for the past 2 weeks anything you want to see i can post please help me solve this
I am using Eclipse not android studio here with also my style.xml
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.App">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="title_text_style" parent="android:Widget.TextView">
<item name="android:gravity">center</item>
<item name="android:padding">5dp</item>
<item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
<item name="android:textColor">#color/white</item>
</style>
<style name="title_bg">
<item name="android:background">#color/light_green</item>
<item name="android:gravity">center</item>
<item name="android:orientation">vertical</item>
</style>
<style name="editext_register_style" parent="android:Widget.EditText">
<item name="android:background">#drawable/edit_bar_bg_register_big</item>
<item name="android:gravity">center_vertical</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:paddingLeft">3dp</item>
<item name="android:textColor">#color/white</item>
<item name="android:textColorHint">#color/white</item>
</style>
<style name="tv_chat_menu_style" parent="android:Widget.Holo.Light.TextView">
<item name="android:gravity">center_horizontal</item>
<item name="android:layout_margin">3dp</item>
<item name="android:textColor">#color/light_green</item>
</style>
<style name="Theme.App" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">#style/Theme.App.ActionBar</item>
</style>
<style name="Theme.App.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="displayOptions">showHome|useLogo</item>
</style>
And this below is the errors i am getting when building
Description Resource Path Location Type
error: Error: No resource found that matches the given name: attr 'actionBarStyle'. styles.xml /Shooteka/res/values-v11 line 7 Android AAPT Problem
error: Error: No resource found that matches the given name: attr 'displayOptions'. styles.xml /Shooteka/res/values-v14 line 12 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Sherlock.Light'. styles.xml /Shooteka/res/values line 48 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Widget.Sherlock.ActionBar'. styles.xml /Shooteka/res/values-v14 line 10 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Sherlock.Light'. styles.xml /Shooteka/res/values-v11 line 5 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Widget.Sherlock.ActionBar'. styles.xml /Shooteka/res/values line 52 Android AAPT Problem
error: Error: No resource found that matches the given name: attr 'displayOptions'. styles.xml /Shooteka/res/values line 53 Android AAPT Problem
error: Error: No resource found that matches the given name: attr 'actionBarStyle'. styles.xml /Shooteka/res/values line 49 Android AAPT Problem
error: Error: No resource found that matches the given name: attr 'actionBarStyle'. styles.xml /Shooteka/res/values-v14 line 7 Android AAPT Problem
error: Error: No resource found that matches the given name: attr 'displayOptions'. styles.xml /Shooteka/res/values-v11 line 12 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Sherlock.Light'. styles.xml /Shooteka/res/values-v14 line 5 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Widget.Sherlock.ActionBar'. styles.xml /Shooteka/res/values-v11 line 10 Android AAPT Problem
Description Resource Path Location Type
The project was not built due to "A resource exists with a different case: '/Shooteka/bin/classes/com/chat'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent Shooteka Unknown Java Problem

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

Categories

Resources