DEV Community

Ibrahim
Ibrahim

Posted on

How to Mirror an Android Screen to Linux Using Scrcpy

Scrcpy is an open source application used to mirror and control the Android screen on a Linux computer.

Here's a step-by-step guide to using Scrcpy on Linux:

1. Install Required Packages

Install the following packages required by Scrcpy:

sudo apt install ffmpeg libsdl2-2.0-0 adb wget \
    gcc git pkg-config meson ninja-build libsdl2-dev \
    libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
    libswresample-dev libusb-1.0-0 libusb-1.0-0-dev
Enter fullscreen mode Exit fullscreen mode

One of the required packages is adb. Check the adb installation using the adb --version command. If it's successful, the output will look like this:

adb --version
# Android Debug Bridge version 1.0.41
# Version 36.0.0-13206524
# Installed as /home/ibrahim/android-sdk/platform-tools/adb
# Running on Linux 5.10.0-35-amd64 (x86_64)
Enter fullscreen mode Exit fullscreen mode

2. Install Scrcpy

Install Scrcpy using this command:

sudo apt install scrcpy
Enter fullscreen mode Exit fullscreen mode

If you want the latest version of Scrcpy, install using this script:

git clone https://github.com/Genymobile/scrcpy
cd scrcpy
./install_release.sh
Enter fullscreen mode Exit fullscreen mode

Check the scrcpy installation using the scrcpy --version command. If it's successful, the command output will look like this:

scrcpy --version
# scrcpy 1.17

# dependencies:
# - SDL 2.0.14
# - libavcodec 58.91.100
# - libavformat 58.45.100
# - libavutil 56.51.100
Enter fullscreen mode Exit fullscreen mode

3. Connect Android to Linux

Connect an Android device to Linux using USB Port.

After connecting the Android device, enable USB Debugging on the Android device by going to Settings > Developer Options > USB Debugging.

Enable USB Debugging

If Developer Options does not appear in the Settings, try these steps:

  1. Open Settings > About Phone > Android Version.
  2. Tap 7x or more in the Android Version until a notification saying 'Developer Options have been enabled' appears.
  3. Open the Developer Options menu again in the Settings and enable the USB Debugging.

Some Android devices may have a different method to enable USB Debugging.

After the USB Debugging is activated, check whether the Android device is successfully connected to Linux by executing the adb devices command. If it's successful the device name should be listed.

adb devices
# List of devices attached
# R9CW700L3BR   device
Enter fullscreen mode Exit fullscreen mode

4. Run Scrcpy

Now run the scrcpy command to start Scrcpy.

scrcpy
Enter fullscreen mode Exit fullscreen mode

If Scrcpy runs successfully, a new window will open showing the Android screen, and you can control the Android device from Linux.

Scrcpy runs successfully

Summary

Mirroring Android screen to Linux has many use cases. For example, I sometimes use it as the emulator when developing Android applications.

If you have trouble while following the steps above, leave a comment below and I will try to help.

Top comments (0)