When demoing the DHIS 2 Capture Android application (and other Android apps), it is quite useful to be able to display the phone screen on your local machine, so that the screen can be shared on video conference calls or projectors. A great application for displaying and controlling your Android device through USB connection (or over TCP/IP) is the scrcpy application from Genymotion. It is cross-platform (GNU/Linux, macOS and Windows) and does not require any root access. For Ubuntu 18.04 and later it is available as a snap package. This guide explains how to install scrcpy on Ubuntu from the command line and connect to your Android device.
-
Ensure you have snapd installed on your system. If not, install it with:
$ sudo apt update $ sudo apt install snapd
-
Install scrcpy with this command:
$ sudo snap install scrcpy
Verify the location of the scrcpy installation with this command:
$ which scrcpy
-
Enable USB debugging on the Android device.
- On the Android device, open the Settings app.
- In the settings app, search for About phone and navigate to that screen.
- Tap the Build number option 7 times. This will enable developer mode on the device.
- Search for Developer options and navigate to that screen.
- Under Debugging, enable USB debugging.
-
Connect your Android device to your local machine using a USB cable.
-
A dialog called Use USB to will appear on the device. Select the Transfer files option.
-
A dialog called Allow USB debugging might appear. If so, select OK.
-
Start scrcpy with this command:
$ scrcpy -t
This will open the scrcpy app and display the Android device on your local machine in an application screen. You can use both the touchscreen on the device and the touchpad/mouse on your local machine to control the screen.
A wealth of options are available which can be explored with
$ scrcpy --help
or from the README file.