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"/>
Related
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
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.
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)
I am new to Ads and was able to successfully add my first ad in my android app using the code below in my layout.
mylayout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="xxx"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
Since I have multiple layouts in my app, I moved the common AdView attributes (e.g. adSize, adUnitId, etc,.) to styles.xml to reduce the code size. However, after this change, I am running into errors like
error: Error: No resource found that matches the given name: attr 'ads:adUnitId'.
error: Error: No resource found that matches the given name: attr 'ads:adSize'.
error: Error: No resource found that matches the given name: attr 'ads:loadAdOnCreate'.
styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" >
<style name="MyAdView">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="ads:adSize">BANNER</item>
<item name="ads:adUnitId">xxx</item>
<item name="ads:loadAdOnCreate">true</item>
</style>
</resources>
I don't have problems with the android:xxx tags, the problem seems to be only with ads:xxx. Is there anything else that I should be doing to use com.google.ads namespace.
Since everything works fine when I have the code in the layout, I think I have everything I needed to add ads in my app (AdMob SDK, admob lib in build path and order & export, etc,.).
Please suggest. Thanks in advance.
I think you can use the style resource only for style related attributes, if you want to factorize the id you should use a string resource like
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="admob_id">XXX</string>
</resources>
i am trying to display Listview control in android app and here is my xml file:
what i am doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="countries">
<item name="usa">Unites States</item>
<item name="kwt">Kuwait</item>
<item name="sa">Sudia Arabia</item>
<item name="uae">United Arab Emirates</item>
<item name="afghan">Afghanstan</item>
</string-array>
</resources>
Error:
[2012-01-08 19:58:24 - ListControls] Error in an XML file: aborting build.
There are a few other questions here on Stackoverflow that may address your problem:
Error starting an Android program
It's worth searching Stackoverflow or the web for error message strings etc. before posting a new question (if you didn't do this).
Try closing Eclipse, then run it again.
i copy your code to eclipse, it work right.
so, may be the eclipse build has some problem, suggestion clean your project and rebuild.
[2012-01-08 19:58:24 - ListControls] Error in an XML file: aborting build.
and maybe your error is not the xml file error.