using-scrcpy.md 2.8 KB

How to use scrcpy

scrcpy is a utility program that projects the screen on an Android device to a machine that's running scrcpy. This program can be used to use Android phones on desktops, which makes app development very easy and should be wonderful for productivity.

Requirements

  • scrcpy is available on Windows, MacOS and Linux - so you'll need one of them. We'll discuss mainly Linux platform here.
  • At least Android 5 Lollipop on your phone
  • Appropriate settings set for the connection (discussed later)

Step -1: Install scrcpy

On Void Linux:

sudo xbps-install scrcpy

On Arch Linux, use a AUR helper to install scrcpy, e.g.

pakku -S scrcpy

For other platforms/distros, consult the scrcpy project page. There is also a snap package if you're interested.

Step - 2: Phone Settings

  • Make sure you have the Developer Options enabled. To enable Developer Options, go to Settings - About phone, then find the build number. The location of that setting may vary depending on device. Then tap the built number couple of times.
  • Go to Settings - System - Developer Options, then turn on Android Debugging / USB Debugging.
  • Depending on your phone, you may also have to set Settings - Developer options - Default USB configuration to PTP or something else other than no data.

Step - 3: Connecting

Connect your phone on your computer with a USB cable.

Run adb devices on terminal. It should output something like:

List of devices attached
78abc123	unauthorized

unauthorized means that you will need to allow this device to connect on your phone. Unlock your phone and you should see a message box titled "Allow USB debugging?". Click OK to allow.

If it outputs:

List of devices attached
78abc123	no permissions; see [http://developer.android.com/tools/device.html]

You will have to set the "Default USB configuration" to PTP or something.

Now running adb devices should say:

List of devices attached
78abc123	device

No run:

scrcpy

It should show your Android screen on a window on your desktop. You can interact with the screen with left click. Right click will work as a back button.

For other options, such as, resize, bit rate, frame rate, crop, lock orientation, screen recording, multi devices, consult the project readme.

Close the window when done.

Troubleshooting

Fix: if scrcpy says Aborted and hangs

adb shell
cd data/local/tmp
rm -rf scrcpy-server.jar
# if doesn't work, restart computer

Source: https://github.com/Genymobile/scrcpy/issues/390#issuecomment-457859811

adb devices shows no permission

sudo adb kill-server
sudo adb start-server