Devices
Android Emulator Automation: Emulators, Cloud and Phone
Android emulator automation in Macro Automation Studio: the emulators it discovers, the adb port rules, adding a device by port, cloud devices and your phone.
- Windows
- Mac
- Emulator
- Cloud device
- Phone
- Studio
- Python SDK
On this page
Android emulator automation in Macro Automation Studio (MAS) starts with a device: an Android emulator on this computer, a cloud device in MAS’s cloud, or, as an advanced path, your own phone. This page explains how MAS finds emulators, how you add one, and where the other two kinds fit.
Before you start
- MAS is installed and you are signed in with an active trial or plan. See Install MAS. MAS is a free download for the trial; get it from the download page.
- For an emulator: the emulator is running and ADB is switched on in its settings. The BlueStacks, LDPlayer, MuMu Player and MEmu guides show where.
- For a cloud device: a plan with the cloud device add-on. See Cloud devices.
How MAS finds the emulator adb port
MAS does not run adb devices to find emulators. It scans the running processes for known emulator names, reads the TCP ports each one is listening on, and keeps a port only when it sits inside that emulator’s known range. Only ports bound to 127.0.0.1, 0.0.0.0 or all interfaces count. The result fills the Port list in the Add New Device dialog, one entry per port with the emulator name next to it.
| Emulator | Process names MAS looks for | Ports MAS accepts |
|---|---|---|
| BlueStacks | HD-Player, BlueStacks | 5555 to 8500 |
| LDPlayer | LdVBoxHeadless, Ld9BoxHeadless, dnplayer, LDPlayer, VBoxNetNAT | Odd ports from 5555 to 5599 |
| Nox | NoxVMHandle | 62001 to 63000 |
| MEmu | MEmuHeadless, MEmuHyper | 21503 and every port ending in 3 above it, below 30000 |
| MuMu Player | NemuHeadless, MuMu | Odd ports from 5555 to 5599, port 7555, 16384 to 16576, or 26624 to 27264 |
Each emulator instance listens on its own port, so two BlueStacks windows show up as two entries. If your emulator is not in the table, or it listens outside its range, you can still type the port by hand.
Add an Android emulator as an automation device
- In MAS, open Device Groups and click Create New Group.
- Enter a Name (3 to 255 characters), keep the type Local, and click Create Group.
- Open the group and click Add Device.
- Enter a Device Name of up to 50 characters.
- Pick the port under Port. Click Refresh to scan again. If the port is missing, choose Custom Port and type it (1024 to 65535).
- Optionally pick a Startup Macro.
- Click Add Device.
The device card shows its port, its macro and its state: Stopped, Connecting, Starting, Running, Stopping or Error. Start connects to the emulator with adb connect 127.0.0.1:<port> and launches the macro; Stop ends the run. A port can belong to one device only; adding it twice fails with “Port is already in use”. To change the port later, click Edit Device.
Several devices in one group can hold different macros, arguments and settings profiles, and Start All runs them one after another. See Device groups.
Cloud devices
A cloud device is an Android device MAS runs for you. You create it on the Cloud Devices page with Create, choosing the Android version, a display preset and a DPI that stay fixed for the life of the device. Start boots it, View opens the live screen streamed over WebRTC, and Run launches a macro that keeps going after you close the app. Stopped devices keep their data; an account can hold up to 20 cloud devices per account. Everything else, including APK installs and quotas, is on the Cloud devices page.
Your own phone
MAS adds every local device by port and always dials 127.0.0.1. There is no USB pairing screen and no wireless pairing screen. A phone therefore works only when its adb daemon can be reached on a TCP port of this computer. Over USB you get there with an adb port forward.
- On the phone, enable Developer options and USB debugging, then plug the phone in.
- On the computer, run
adb devicesand accept the authorization prompt on the phone. The phone’s serial must show asdevice. - Tell the phone’s adb daemon to also listen on TCP:
adb tcpip 5555. - Forward a local port to it:
adb forward tcp:5580 tcp:5555. Pick any free local port; 5580 is only an example. - Check it:
adb connect 127.0.0.1:5580should report “connected”. - In MAS, add a device with Custom Port set to
5580.
Keep the phone plugged in and its screen on. Screen size and DPI come from the phone, so templates cropped on an emulator will not match; crop them from the phone in Asset Lab.
Wireless debugging works the same way once the phone is paired and connected with adb connect <phone-ip>:<port>: forward a local port to the phone’s adb port and add that local port in MAS.
Control it from Python
The SDK does not care which kind of device is underneath. mas.get_device_info() returns the name and screen size, mas.get_screen_size() the size alone, and every tap, swipe and screenshot goes through the same calls. Scripts are launched by MAS with the device already bound, so there is nothing to connect in code. Start with the SDK overview.
Troubleshooting
The Port list is empty
The emulator is not running, ADB is off in its settings, or it is not one of the emulators MAS scans for. Click Refresh after the emulator finishes booting. If it is still empty, use Custom Port with the port shown in the emulator’s own settings. See ADB troubleshooting.
Port is already in use
Another device in one of your groups already owns that port. Each port can be added once. Remove the old entry or pick the other instance’s port.
The device stays on Connecting or ends in Error
MAS could not complete adb connect, or the emulator refused the first command. Check the port, confirm ADB is on, and follow ADB troubleshooting.
Next steps
Related pages
Thanks. If something is wrong, tell us in Discord.
Questions? Ask in Discord