Mirror Android device on desktop screen with scrcpy
Tags: android, linux, macos, windows
Published: 2021-12-29 15:16:05

A growing number of services such as online banking are accessible on mobile devices only these days, so you may find yourself typing IBANs or reference numbers on tiny on-screen keyboards while your desktop computer keyboard sits right next to it laughing at you.

Stop this, let's mirror the Android device on the desktop screen!

There are quite a few commercial remote control solutions out there, some of which offer limited free tiers once you've registered online. However, particularly when it comes to remote access, I prefer open-source tools which don't require any third party server.

Enter [scrcpy](https://github.com/Genymobile/scrcpy), a lightweight CLI tool available for macOS, Linux and Windows. It communicates via ADB which is preinstalled on every Android device and doesn't require it to be rooted.

## Prep the Android device

On the Android device, open developer options and enable «Android debugging (ADB)». (In case you don't find the developer options, you have to [enable those beforehand](https://developer.android.com/studio/debug/dev-options).)

ADB requires a USB connection by default which is secure, but not very handy. If **and only if** you are on a secure private network, you may use a TCP/IP connection instead, say your home wifi network. Check available widgets, you might find one called «ADB over network» to easily switch this feature on and off.

Just to make sure you've understood the risks: **Never enable «ADB over network» on insecure public networks!**

## Install scrcpy on the desktop computer

The following is for Macs, but you find instructions for Linux or Windows on the [scrcpy README](https://github.com/Genymobile/scrcpy).

Unless already present, install [Homebrew](https://brew.sh) on your Mac. Then open a terminal and install scrcpy as well as the offical Android development tools.  

```shell
brew install scrcpy
brew install android-platform-tools
```

You might also want to set an aliases in order not having to memorize scrcpy and it's options. Here's the alias when using a USB connection:

```shell
# macOS 12 or newer
echo 'alias android="scrcpy --stay-awake"' >>~/.zshrc
source ~/.zshrc

# macOS 11 or older
echo 'alias android="scrcpy --stay-awake"' >>~/.bash_profile
source ~/.bash_profile
```

When using a TCP/IP connection, you have to make sure your Android device always gets the same IP address assigned by the router. The following assumes the device on IP 192.168.1.10:

```shell
# macOS 12 or newer
echo 'alias android="scrcpy --tcpip=192.168.1.10 --bit-rate 2M --max-size 800 --stay-awake"' >>~/.zshrc
source ~/.zshrc

# macOS 11 or older
echo 'alias android="scrcpy --tcpip=192.168.1.10 --bit-rate 2M --max-size 800 --stay-awake"' >>~/.bash_profile
source ~/.bash_profile
```

## Spieglein, Spieglein

Time to mirror! Either connect the Android device to the computer or enable «ADB over network», then open a terminal on the Mac and type:

```shell
android
```

A window should pop up and mirror the Android screen. You can mouse around, type input, even copy/paste as if it were just another application running. 🎉

Given the multitude of different Android devices, this might not work at the first attempt. You find troubleshooting hints in the [scrcpy README](https://github.com/Genymobile/scrcpy).

(Photo by <a href="https://unsplash.com/@rishabhdharmani?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Rishabh Dharmani</a> on <a href="https://unsplash.com/s/photos/mirror?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>)