Android autofill: dispatchProvideAutofillStructure() not laid out Android autofill: dispatchProvideAutofillStructure() not laid out android android

Android autofill: dispatchProvideAutofillStructure() not laid out


I'm the Android Frameworks engineer leading the Autofill Framework project, so I'll answer some questions:

  • The "Contents can't be autofilled" message typically means the Autofill Service does not know how to autofill the screen. When you're adding autofill support to your app, it's often easier to use an Autofill Service you can control first, rather than a "real" service like a password manager. As mentioned in a previous reply, we provide a sample service that can be used for this purpose.
  • When you long-press a text field and select AUTOFILL, you are in fact "forcing" an autofill request as mentioned in another reply (i.e., behind the scenes the text field is calling AutofillManager.requestAutofill()). If the Autofill Service knows how to autofill your screen, you shouldn't need to do that, as the autofill suggestions would show up right away once you focus the input field.
  • You shouldn't need to set importantForAutofill or call AutofillManager.cancel() in your case.

So, my recommendation is to try to use the sample Autofill Service implementation to test your app first. Most likely, the first time you access your app the autofill popup won't be shown because the service does not have data for it. But once your app triggers the save UI (for example, after you manually enter the phone number and the activity finishes) and you tap save, that data should be available the next time you launch the activity.

Hope that helps,

-- Felipe


This may well be the issue - as

as service for ComponentInfo{com.google.android.gms/com.google.android.gms.autofill.service.AutofillService} is already destroyed

Ensuring data is available
In some special cases, you need to take additional steps to make sure that the data is available to the Autofill Framework to save. For example, an activity can present a layout with standard text views, but then destroy the layout and replace it with one without child views, such as GLSurfaceView.

In this case, the data in the original layout is not available to the framework. To make the data available to the framework, you should call commit() on the AutofillManager object before replacing the original layout.

You'll need to fix some of these issues within your java code.

Add IMPORTANT_FOR_AUTOFILL_AUTO and check that autofill isenabled().

You may need to manage some of the settings within the java force the Autofill request:

Sometimes, you may need to force an autofill request to occur in response to a user action. .../...

public void eventHandler(View view) {    AutofillManager afm = context.getSystemService(AutofillManager.class);    if (afm != null) {        afm.requestAutofill();    }}


Do you have an app on you phone that implements an Autofill service? I tried it with "Autofill with Google" service, and could got my phone number autofilled without problems (with emulator running SDK 26). You will need a service part for get the autofill working. See this example.