Free open-source solution to cast your Android screen

20181103
Photo by Jonathan Kemper / Unsplash

As a mobile developer we are often asked to demo our work. In the Android world there are many ways of doing that :

  • Vysor : free but with ads
  • AllCast : free with watermark and no remote control (a click on desktop mapped to a click on mobile)
  • ... many others

I'm going to introduce you to Scrcpy

ScrCpy

This application provides display and control of Android devices connected on
USB (or over TCP/IP). It does not require any root access. It works on GNU/Linux, Windows and macOS.

Requirements

The Android device requires at least API 21 (Android 5.0).

Make sure you enabled adb debugging on your device(s).

On some devices, you also need to enable an additional option to control it using keyboard and mouse.

More about ScrCpy on their README.md

And ScrCpy also allows you to control your android device through your laptop !

Automatic installation script

On Mac you can install ScrCpy with a simple Homebrew line.

Here is a bash script that installs ScrCpy for you (if needed) and starts it :

#!/usr/bin/env bash
# 
# Script to start Scrcpy

if test ! $(which scrcpy); then

    echo "Starting installation"
  
    # Check for Homebrew, install if we don't have it
    if test ! $(which brew); then
        echo "Installing homebrew..."
        ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    fi

    # Update homebrew recipes
    brew update

    echo "Installing scrcpy..."
    brew install scrcpy

    if test ! $(which adb); then
        echo "Installing android-platform-tools..."
        brew cask install android-platform-tools
    fi
    
    echo "Scrcpy is installed, you may need to restart your terminal"
    echo "Your Homebrew might be messy now, to cleanup run :"
    echo "    brew cleanup"
    echo ""
    
    #reloading terminal
    source ~/.bash_profile
fi

scrcpy

To install ScrCpy on other platforms (Windows, Linux) please refer to the documentation : README.md

I might do the equivalent script for windows in the future.

Let me know if it helped 😉