# MuMu Player ADB Port and Connect Setup for MAS

> Find the MuMu Player 12 ADB port, connect Macro Automation Studio to it, add every instance as a device, and run MAS macros instead of the recorder.

Source: https://automationmacro.com/docs/mumu-setup-guide (Devices, updated 2026-09-04)

This guide shows how to find the MuMu Player 12 ADB port and connect the instance to Macro Automation Studio (MAS), and explains how MAS macros differ from MuMu's Operation Recording. The steps target Windows; a short section covers the Mac build.

## Before you start

- MAS installed and signed in on Windows 10 or 11, or on an Apple Silicon Mac. MAS is a free download for the trial; get it from the [download page](/download).
- MuMu Player 12 installed from [mumuplayer.com](https://www.mumuplayer.com/) and started once.
- The instance fully booted to the Android home screen.
- The apps you want to automate installed and signed in inside MuMu Player.

## 1. Install MuMu Player 12

1. Download MuMu Player 12 from the vendor site and run the installer.
2. Start MuMu Player and wait for the home screen.
3. Install and sign in to the apps you want to automate before you add the device to MAS.

## 2. Set a fixed resolution

MAS matches template images pixel for pixel, so pick a resolution once and keep it.

1. Click **Settings** at the upper right of the MuMu Player window.
2. Open **Display** and choose a custom resolution.
3. Enter a width of 540, a height of 960 and a DPI of 240. This is the MAS baseline; a macro you write yourself expects whatever resolution you captured in Asset Lab.
4. Save and restart the instance when MuMu Player asks.

> [!WARNING]
> Changing the resolution after you capture templates moves every match. MuMu's own recorder has the same rule.

## 3. Enable ADB in MuMu Player 12

The vendor's ADB guide shows no toggle for MuMu Player 12. A running instance answers adb on its port without any setting, so what you need is the port number:

- For a single instance, open the menu at the top right of the window and choose **Issues Diagnostic**. The ADB debugging port is listed there.
- For several instances, open **MuMuPlayer Multi-instance 12** and click the ADB icon on a running instance to show its port.

## 4. The MuMu Player ADB port and how MAS scans it

MuMu Player 12 gives its main instance port **16384** and each further instance adds 32: 16416, 16448 and so on. When a port is taken, MuMu adds 1, so 16385 can appear. MAS does not use `adb devices` to discover emulators. It scans the running processes and keeps a port when all of these hold:

- The process name contains `nemuheadless` or `mumu`.
- The port is between 16384 and 16576, between 26624 and 27264, exactly 7555, or an odd port between 5555 and 5599.
- The socket listens on `127.0.0.1`, `0.0.0.0` or all interfaces.

The 16384 to 16576 range covers the main instance and the next six; 7555 and the 5555 range come from older MuMu versions. Matching ports appear in the **Add New Device** dialog labelled `MuMu`, for example `16384 - MuMu`. MAS scans when you open a device group and each time you click **Refresh**.

## 5. Connect MuMu Player over ADB in MAS

1. Open **Device Groups** in the sidebar and open a group, or create one.
2. Click **Add Device**.
3. Type a **Device Name** of up to 50 characters.
4. In **Port**, pick the `MuMu` entry for this instance. Click **Refresh** if the list is empty.
5. If the port shown in **Issues Diagnostic** does not fit the rule above, choose **Custom Port** and type it. MAS accepts 1024 to 65535.
6. Optionally choose a **Startup Macro**.
7. Click **Add Device**, then click **Start** on the device card.

The card shows **Connecting** and then **Running**. MAS starts its own adb server, removes any stale entry for `127.0.0.1:<port>`, and runs `adb connect` against it.

## Macros on MuMu Player

MuMu's **Operation Recording** records taps and replays them from a file, with three stop conditions (**Execute x times to stop**, **Execute xx time to stop** and **Infinite loop to manual stop**) and a **Cycle interval**. The vendor warns that the resolution at playback must match the recording. The file replays fixed coordinates without looking at the screen, so a slow load, a pop-up or a moved button breaks the sequence, and it runs only inside MuMu Player.

A MAS macro is a Python script that checks the screen before it acts: it finds a button with template matching, reads text with OCR, waits with retries, and branches on what it sees. The same script runs on MuMu Player, other emulators and cloud devices without edits, because MAS drives every device over adb.

- To rebuild a recording as a screen-aware macro, follow [Image recognition macros](/docs/guides/image-recognition-macros).
- To loop it until a condition is met, or run it on a schedule, read [Loops, stop conditions and scheduling](/docs/guides/loops-and-scheduling).

> [!NOTE]
> End any running Operation Recording before you start a device in MAS. Both send input to the same screen and interfere with each other.

## Several MuMu instances

Open **MuMuPlayer Multi-instance 12** from the toolbox icon at the upper right. **+New** creates an instance and **Device setting** sets its performance and display, so give every instance the same resolution. Each instance listens on its own port, 32 above the previous one. Add each as a separate device in the same device group, assign a macro and settings profile per device, and use **Start All** and **Stop All** on the group. From the eighth instance on, the port passes 16576 and MAS no longer lists it; add it with **Custom Port**. See [Device groups](/docs/device-groups) for per-device arguments and proxies.

## MuMu Player on Mac

MuMu also ships a build for Apple Silicon Macs. There the vendor's guide puts ADB in the menu bar: with a device running, open **Tools** and choose **Open ADB (device port number)**. The entry shows the port; the default is again 16384. If the scan in MAS does not list it, add it with **Custom Port**.

MAS on a Mac needs an adb binary: it looks inside its app bundle, then on your PATH, then in the Homebrew folders. If MAS reports "ADB executable not found. Please install ADB using your package manager", install adb with Homebrew and restart MAS:

```bash
brew install android-platform-tools
```

MAS always dials `127.0.0.1`, so MuMu Player must run on the same Mac.

## Troubleshooting

### MuMu ADB port

MAS lists no `MuMu` entry, or the entry it lists belongs to another instance.

- Read the port from **Issues Diagnostic** or from the ADB icon in **MuMuPlayer Multi-instance 12** and compare it with the device card; fix it with **Edit Device**.
- Count from 16384 in steps of 32 per instance, plus one when a port was taken (16385 instead of 16384).
- The instance is still booting, so the port is not open yet. Wait for the home screen and click **Refresh**.
- The port is above 16576 or otherwise outside the scan rule. Choose **Custom Port** and type it.

### MuMu ADB connect fails

The device card shows **Error** with "Failed to start device", the log says "unable to connect to device", or adb prints "cannot connect" or "connection refused".

- Nothing listens on that port. Check the number as above and confirm the instance is running.
- A second adb server holds a stale entry. Close other tools that run their own adb server, click **Stop**, restart the instance, and click **Start**; MAS reconnects from scratch.
- `adb devices` shows the port as `offline`. Restart the instance; if it stays offline, restart MAS so its adb server starts clean.
- The scan reported "Failed to scan emulator ports". Restart MAS and open the dialog again.

To see adb's raw reply, run `adb connect 127.0.0.1:16384` in a terminal. More fixes are on [ADB troubleshooting](/docs/adb-troubleshooting).

### Macro loop on MuMu

A recording set to **Infinite loop to manual stop** cannot tell whether the loop should continue, so it keeps tapping after the goal is reached or a pop-up appears. A MAS macro loops in Python with a stop condition: a template that appears, a number read by OCR, or a count of passes. [Loops, stop conditions and scheduling](/docs/guides/loops-and-scheduling) shows the patterns. If a MAS loop stalls, open **Logs** on the device card: `ImageNotFoundError` and `TimeoutError` name the failed step, and the usual cause is a resolution that no longer matches the templates.

## Control it from Python

With the card at **Running**, a macro's `src/app.py` drives the instance through the `mas` package. MAS chooses the port, so scripts never reference it.

```python
import mas

size = mas.get_screen_size()
mas.log(f"MuMu screen is {size.width}x{size.height}")

match = mas.find_object_retry(1234, total_tries=3, time_sleep=2.0)
if match:
    mas.click(match.x, match.y)
```

Read the [SDK overview](/docs/sdk) for every namespace, and [Control an Android emulator from Python](/docs/guides/control-an-emulator-from-python) for a complete first script.
