# Android Native

<figure><img src="https://1411608689-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCbCMt5C3rawmE9oIus7f%2Fuploads%2FfSMqKmjPVgES4X8KSvRQ%2Fimage.png?alt=media&#x26;token=e6c7eb29-cb29-41cc-b92f-9eee1f8856db" alt=""><figcaption></figcaption></figure>

Maestro provides a black-box testing approach for native Android applications. By interacting with the app through the Android Accessibility layer rather than internal code instrumentation, you can test production-ready binaries without modifying your source code.

### Technical advantages

* **Zero Instrumentation**: No custom Gradle configurations, `build.gradle` dependencies, or test-specific APK builds are required. You test the exact binary your users receive.
* **Refactoring Resilience**: Migrating your UI implementation will not break your tests as long as the user-visible text or semantic IDs remain consistent.
* **UI-Layer Interaction**: Maestro interacts with rendered UI elements, ensuring that tests validate the actual user experience rather than internal component states.

### Element interaction strategies

In Android development, Maestro leverages the accessibility layer of the device to identify and interact with elements via primary methods:

* **Text Selection**: Target any view with a `text` property (e.g., `Button`, `TextView`).

  ```yaml
  - tapOn: "Login"
  ```
* **Resource ID**: Access views by their `android:id`. This is ideal for disambiguating identical text elements.

  ```yaml
  - tapOn:
      id: "login_button"
  ```
* **Content Description**: The `android:contentDescription` attribute is surfaced as a text property, making it the "gold standard" for automating icons and image-based buttons.

  ```yaml
  - tapOn: "Settings Icon"
  ```
* **Hints**: For input fields that have not yet been filled, the `android:hint` attribute is also exposed to the text selector.

#### Handling lists and dynamic content

Native Android often uses `RecyclerView` or `LazyColumn` for long lists. Maestro abstracts the complexity of view recycling through intelligent scrolling.

Instead of calculating scroll offsets, use the built-in intelligence of Maestro to find elements that are currently off-screen:

```yaml
- scrollUntilVisible:
    element:
        text: "Item #50"
    direction: DOWN
```

Maestro will automatically swipe down, wait for the next items to load, and stop only when the target element is detected in the view hierarchy.

### Known limitations

While Maestro can detect and tap on views containing Unicode characters, direct inputting (typing) of Unicode text via the `inputText` command is currently not possible.

### Next steps

If you don't know how to create tests with Maestro, access the [QuickStart](https://docs.maestro.dev/get-started/quickstart) guide to get up and running in minutes.

To learn how to create tests, refer to the [Flows](https://app.gitbook.com/s/mS3lsb9jRwfRHqddeRXG/) documentation. If you want to explore Maestro solutions, consult the appropriate documentation:

* [Maestro Studio](https://app.gitbook.com/s/eQi66gxHTt2vx4HjhM9V/)
* [Maestro CLI](https://app.gitbook.com/s/kq23kwiAeAnHkGJYMGDk/)
* [Maestro Cloud](https://app.gitbook.com/s/ky7LkNoLfvcORtXOzzBs/readme)
