OpsCanary
awsecsPractitioner

Run Maestro Tests on Real Android Devices with AWS Device Farm

5 min read AWS DevOps BlogNov 6, 2026Reviewed for accuracy
Share
Practitioner — Hands-on experience recommended

In the world of mobile app development, ensuring your application works flawlessly across different devices is crucial. Running tests on real Android devices can uncover issues that emulators often miss. AWS Device Farm provides a fully managed service that lets you test your Android applications on actual devices in the cloud, while Maestro offers a robust framework for mobile UI testing using a simple YAML syntax.

The process begins with AWS Device Farm provisioning a real Android device alongside an Amazon Linux 2023 test host, which comes pre-equipped with ADB (Android Debug Bridge). During the installation phase, your test specification downloads and installs Amazon Corretto 21 (Java) and the Maestro CLI. Once set up, Maestro connects to the device through ADB and executes your defined test flows. It captures essential artifacts like screenshots and video recordings, storing them in the $DEVICEFARM_LOG_DIR directory for easy access after the test run.

In production, you need to ensure your Android .apk file is ready for testing—ideally a release build with animations disabled for better stability. Familiarity with the AWS Device Farm Console is also necessary, as is having your Maestro test flows written in YAML. Be aware that this approach currently supports Android devices only; as of 2026, Maestro's iOS support is limited to simulators and does not extend to real physical iOS devices. This limitation can significantly impact your testing strategy if you're also targeting iOS users.

Key takeaways

  • →Use Amazon Linux 2023 as the host environment for your tests.
  • →Install Amazon Corretto 21 and Maestro CLI during the setup phase.
  • →Define your test flows in YAML to leverage Maestro's capabilities.
  • →Capture and review artifacts like screenshots and videos from $DEVICEFARM_LOG_DIR.
  • →Ensure your Android .apk is a release build with animations disabled for stability.

Why it matters

Running tests on real devices helps catch issues that emulators overlook, ensuring a smoother user experience. This can lead to higher app ratings and reduced churn.

Code examples

YAML
1version: 0.1
2# Use the Amazon Linux 2023 host environment
3android_test_host: amazon_linux_2023
4
5phases:
6  install:
7    commands:
8      # Set locale (important if your app uses special characters)
9      - export LANG=en_US.UTF-8
10      - export LC_ALL=en_US.UTF-8
11      - export LANGUAGE=en_US.UTF-8
12      - locale
13
14      # Install Amazon Corretto 21 (required by Maestro)
15      - echo "Downloading Amazon Corretto 21..."
16      - curl -L -o /tmp/java21.tar.gz https://corretto.aws/downloads/latest/amazon-corretto-21-x64-linux-jdk.tar.gz
17      - mkdir -p /tmp/java21
18      - tar -xzf /tmp/java21.tar.gz -C /tmp/java21 --strip-components=1
19      - export JAVA_HOME=/tmp/java21
20      - export PATH=$JAVA_HOME/bin:$PATH
21      - java -version
22
23      # Install Maestro CLI
24      - curl -Ls "https://get.maestro.mobile.dev" | bash
25      - export PATH="$PATH:$HOME/.maestro/bin"
26
27  pre_test:
28    commands:
29      # Grant background permissions to Maestro driver (for MIUI devices)
30      - adb shell appops set dev.mobile.maestro RUN_IN_BACKGROUND allow 2>/dev/null || true
31      - adb shell appops set dev.mobile.maestro START_ACTIVITIES_FROM_BACKGROUND allow 2>/dev/null || true
32      - maestro --version
33
34  test:
35    commands:
36      # Run Maestro test flows
37      - maestro test -e APP_ID={YOUR_APP_ID} "$DEVICEFARM_TEST_PACKAGE_PATH/.maestro" --test-output-dir=$DEVICEFARM_LOG_DIR/maestro-results
38
39  post_test:
40    commands:
41      - echo "E2E tests completed"
42
43artifacts:
44  # Collect all Maestro output (screenshots, videos, logs)
45  - $DEVICEFARM_LOG_DIR

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →
DigitalOceanSponsor

Simple, affordable cloud — VMs, Kubernetes, and managed databases in minutes. Trusted by 600,000+ developers. Spin up a Droplet in 60 seconds.

Try DigitalOcean →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.