Ofir A. Ofir A. - 1 month ago 7x
Android Question

Android Uiautomator not recognized the programatically view id

I have layout that I build using Java - not from XML file.

I'm assigning to each view an arbitrary id through the Java code:

For instance:

Button btn = new Button(this);

The problem is that the uiautomator, from the Android tools, is not recognize the id - I get empty id.

When I'm using XML file to add the button, all is working fine.

So my question is, what is the problem with the dynamically setting of the id,
what are the changes between the two and why uiautomator isn't recognize the dynamically id?

P.S. Currently I prefer not the change all layouts to XML's


It's an UIAutomator limitiation.. UIAutomator only detects the objects listed in XML layouts