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

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.

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

No resource identifier found for attribute 'alpha' in package 'android.support.design'

I created a library project from
android-sdk\extras\android\m2repository\com\android\support\design\design-25.0.1.aar
I added appcompat, recyclerview and cardview libraries.
There is an error message:
design_25.0.1\res\color\design_tint_password_toggle.xml:19: error:
No resource identifier found for attribute 'alpha' in package 'android.support.design'
This is the code of design_tint_password_toggle.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:state_checked="true" android:color="?android:attr/colorForeground" app:alpha="0.54"/>
<item android:color="?android:attr/colorForeground" app:alpha="0.38"/>
</selector>
How can I fix this error?
Its work for me.
Change here:-
xmlns:app="http://schemas.android.com/apk/res-auto">
to
xmlns:app="http://schemas.android.com/apk/lib-auto">
I found doing a clean build first fixed this issue for me. (I was trying to upgrade from 23.0.1 -> 24.2.1)

Couldn't resolve resource #id/visible when using TextInputLayout

Couldn't resolve resource #id/visible when using TextInputLayout on appcompat-v7:25.x.x
Tried these steps below, but the problem is still persist:
Rebuild Project
Clean and Rebuild Project
Clear Cache and
Restart Android Studio
Below is the code in the layout file.
<android.support.design.widget.TextInputLayout
android:id="#+id/tilFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/etFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/first_name"
android:inputType="textPersonName"/>
</android.support.design.widget.TextInputLayout>
Below is the message displayed in Android Studio
Rendering Problems.
Couldn't resolve resource #id/visible
Tip: Try to refresh the layout.
NOTE: #id/visible is not present in the code.
This nags one with the Rendering Problems window
How to fix: add these values to any values file (the filename doesn't appear to matter, I use ids.xml, you can use an existing one as well, such as colors.xml or strings.xml)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="visible" type="id"/>
<item name="masked" type="id"/>
</resources>
It most likely is a bug, and it has been filed in the Issue Tracker.
Meanwhile, you may try to switch the API version in the editor to 19 or below, though you may see some minor differences in the design output.
No Need To Change API
Couldn't resolve resource #string/faq_customer_service
or
Couldn't resolve resource #id/visible
or
Couldn't resolve resource #id/masked
The solution is if you implement TextInputLayout the above problems may arise ... so Simply add those id or strings to xml files as their property.
Add the value below tag in strings.xml file:
<item name="visible" type="id"/>
<item name="masked" type="id"/>

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

How to make aapt.exe resolve android styles in SDK Tools r12

Since updating my SDK Tools to r12, an existing project (with zero code
changes) now fails during aapt generation with:
[INFO] C:\Dev\Android-sdk\platform-tools\aapt.exe [package, -m, -J,
C:\Source\android\Jumblee\target\generated-sources\r, -M,
C:\Source\android\Jumblee\target\filtered-manifest\AndroidManifest.xml,
-S,
C:\Source\android\Jumblee\target\generated-sources\combined-resources\res,
--auto-add-overlay, -I,
C:\Dev\Android-sdk\platforms\android-10\android.jar]
[INFO]
C:\Source\android\Jumblee\target\generated-sources\combined-resources\res\values\theme.xml:16:
error: Error retrieving parent for item: No resource found that
matches the given name '#android:style/WindowTitle.
The relevant lines from the resource file are:
<!-- Set the theme for the window title -->
<!-- NOTE: setting android:textAppearance to style defined above --
<style name="CustomWindowTitle" parent="#android:style/WindowTitle">
<item name="android:textAppearance">#style/CustomWindowTitleText</item>
</style>
Has anyone seem something similar?
Or better still know wtf is going on?
OK the issue I raised was http://code.google.com/p/android/issues/detail?id=18659
It turns out that #android:style/WindowTitle and a few other styles that people have been using are not published styles.
So the proper solution is to stop using those private styles. And the most appropriate way of doing that it is probably to copy the style in question to your own project and make it your own style.
Found Hot Fix, but yes it's just hot fix. Looking for better solution.

Categories

Resources