Mirror Android Device to Computer

By  on  

As I continue my adventure into Android development, pair programming has been a huge help in learning this new platform. When it's time to build and run the app, relying on the emulator is a fools' game -- the emulator is slow and it's hard to reliably simulate gestures.

If you have an android device, like a phone or tablet, you can plug it into your computer and mirror the display to your computer using an awesome utility called scrcpy!

Start by installing scrcpy with Homebrew:

brew install scrcpy

You may also need to install adb:

brew cask install android-platform-tools

Once you have scrcpy installed, you can start mirroring your Android phone to your computer by executing the command:

scrcpy

The Android device, whether phone or tablet, obviously must be connected to the computer at the time. The mirroring is super responsive and much nicer than an Android emulator. I love using scrcpy to pair program or record videos of app interactions.

When I first started Android development, I was worried I'd be stuck trying to use an emulator to demo features or bugs. Big thanks to scrcopy for making Android life easier!

Recent Features

  • By
    5 Ways that CSS and JavaScript Interact That You May Not Know About

    CSS and JavaScript:  the lines seemingly get blurred by each browser release.  They have always done a very different job but in the end they are both front-end technologies so they need do need to work closely.  We have our .js files and our .css, but...

  • By
    Introducing MooTools Templated

    One major problem with creating UI components with the MooTools JavaScript framework is that there isn't a great way of allowing customization of template and ease of node creation. As of today, there are two ways of creating: new Element Madness The first way to create UI-driven...

Incredible Demos

  • By
    Build a Toggling Announcement Slider Using MooTools 1.2

    A few of my customer have asked for me to create a subtle but dynamic (...I know...) way for them to advertise different specials on their website. Not something that would display on every page, but periodically or only the homepage. Using a trick...

  • By
    Upload Photos to Flickr with PHP

    I have a bit of an obsession with uploading photos to different services thanks to Instagram. Instagram's iPhone app allows me to take photos and quickly filter them; once photo tinkering is complete, I can upload the photo to Instagram, Twitter, Facebook, and...

Discussion

  1. Akis

    Thank you David! Nice tool but on macOS 10.13.6 with adb on PATH and after successfully wireless connected (through adb) to my Xiaomi Mi 9, running

    scrcpy

    I took this error log:

    ERROR: Command not found: [~/Android/platform-tools/adb scrcpy], [push], [/usr/local/Cellar/scrcpy/1.11/share/scrcpy/scrcpy-server], [/data/local/tmp/scrcpy-server]
    ERROR: (make 'adb' accessible from your PATH or define its fullpath in the ADB environment variable)
    ERROR: Could not execute "adb push"
    

    Everything works but scrcpy… Any idea?

  2. Akis

    Actually, by removing

    export ADB="$ANDROID_SDK_HOME/platform-tools/adb scrcpy"

    from my .bash_profile, the first error line reads:

    ERROR: Command not found: [adb], [push], [/usr/local/Cellar/scrcpy/1.11/share/scrcpy/scrcpy-server], [/data/local/tmp/scrcpy-server]

    I pushed (with “adb push”) the appropriate file successfully on my phone, just to test if adb push command works.

  3. JJS

    If you use the Android Emulator from Google based on x86 processor with HAXM, it’s superfast, and superfast loaded. If you use the ARM images it’s slow as hell indeed.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!