I have an issue with Palette -> Text
When I want to set some view, I receive a message problem "Missing autofillHints attribute"
Any suggestions?

- 17,392
- 11
- 61
- 88

- 1,339
- 3
- 7
- 6
-
1`tools:ignore="Autofill"` is only way to ignore for now. – Pratik Butani Nov 30 '18 at 05:46
4 Answers
Perhaps you are using an EditText
. autofillHints
is used in API 26 and above for filling empty EditText
s and it's actually suggesting which type of content should be placed in there.
Just add :
android:autofillHints="username" // the type of content you want
To your EditText
and warning will disappear.
You do this using the new
android:autofillHints
attribute to tellautofill
what type of content you expect, andandroid:importantForAutofill
to tellautofill
which views you want (or do not want) to be filled.
Read: https://medium.com/@bherbst/getting-androids-autofill-to-work-for-you-21435debea1
And this: https://developer.android.com/guide/topics/text/autofill-services
Edit:
You can however set:
android:importantForAutofill="no"
To the component to tell it is not important to fill and get rid of the error.

- 16,646
- 7
- 53
- 108
-
Again errors :( "Missing accessibility label" "Attribute unused on older version" – Sebastian Oct 07 '18 at 16:38
-
-
Again errors :( "Missing accessibility label" "Attribute unused on older version" – Sebastian Oct 07 '18 at 16:40
-
-
You can actually. Add the picture in your question (use edit button). However, those are just warnings which can be bypassed by adding `tools:targetApi="o"`. – ʍѳђઽ૯ท Oct 07 '18 at 16:45
-
I changed API level from API 28 to API 25 and it worked!! but I have a question, was it good option to change level? – Sebastian Oct 07 '18 at 16:48
-
It's up to you. However, you could use the latest API and just adding `tools:targetApi="o"` because it is available from API 26 and up so, no need to be worried. It's actually not a good idea to downgrade the API. Those were just **warnings** which could be ignored or bypassed. – ʍѳђઽ૯ท Oct 07 '18 at 16:53
-
I did as it how you told me and it worked !! thanks a lot and have a nice evening :) – Sebastian Oct 07 '18 at 17:06
-
1Note: "importantForAutofill" is only used in API level 26 and higher – bunkerdive Apr 16 '19 at 06:38
If you don't want autofillHints
minSdk>=26 .
Should use android:importantForAutofill=no
if you don't want autofill hint
<EditText
android:importantForAutofill="no"/>
minSdk<26
Add android:importantForAutofill
then tools:targetApi
to make IDE don't this warning about API level
<EditText
android:importantForAutofill="no"
tools:targetApi="o"
/>
If you want autofillHints
Autofill service enable by default even if we don't set autofillHints
attribute. specify an autofillHints will help autofill service work better like our expection. see documents here
minSdk>=26
Just need to add
android:autofillHints="{a contant value}"
(eg:"android:autofillHints="password"
) (use constant from here)
minSdk<26, add tools:targetApi
to make IDE don't this warning
<EditText
android:autofillHints="emailAddress"
tools:targetApi="o"/>
Note
autofillHints
andimportantForAutofill
only used in API 26 and higher but we still can use it in API < 26 without crash (you can see in this answer) (it don't crash but ofcourse it don't have any effect with API < 26)tool:...
just use to make IDE don't warning, it will not effect anything when application running sotools:ignore="Autofill
don't help you hide autofill hint

- 57,942
- 23
- 262
- 279
-
2According to the documentation - https://developer.android.com/reference/android/view/View.html#setAutofillHints(java.lang.String...) - the `android:autoFillHints` constant for an email address is `emailAddress` rather than just `email`. – ban-geoengineering Apr 29 '20 at 12:17
-
@ban-geoengineering this comment was more useful for me than the entire answer. Thanks a ton – Kartik Jul 08 '20 at 07:15
-
This answer is better structured & more readable than the accepted one. – Touhid Aug 18 '20 at 18:52
you need to the strings.xml file and enable the string text in there, for example:
<string name="editText2">Name</string>.
then you need to activity_mail.xml
- and then enable the autofillhint activity there, by using:
android:hint="@string/editText2"

- 2,377
- 5
- 29
- 58

- 43
- 4
For me first, I wrote this but had error:
<EditText
android:autofillHints="Name"
....../>
So I changed it in the form below and worked:
<EditText
android:hint="Name"
....../>
You can always suppress it if you do not need with:
<EditText
android:importantForAutofill="no"
....../>

- 1
- 2