Hacker News new | past | comments | ask | show | jobs | submit login
Scrcpy – An app to display and control Android devices (rom1v.com)
317 points by rom1v on March 8, 2018 | hide | past | favorite | 56 comments

This is an example of one of those applications that work so well, consists of simple parts, and leverages these simple tools very cleverly.

It's a solution that I think 'why didn't I write this?'

Very awesome work rom1v, and very much appreciate you explaining your usage of adb screenfetch and how you are able to arbitrarily run java code from /tmp. This opened up an entire new world for me.

This seems pretty neat. What is the purpose of such an app though? Is it intended for use by Android developers? I don't see what I'd use it for but I'm interested in how people use the app.

It has been devoloped for a specific use case (it is included in a B2B application where the user may need to display and control devices connected on USB).

But you might use it for other reasons, like typing text messages from your computer, or showing your device in a conference (e.g. to demo an app).

Demoing an app on Android has been a pain, so far. Vysor was the easiest solution but comes with ads if you don't buy the license. This seemingly being an ad-free alternative makes it very interesting to me and my team.

Only thing is I tried to compile the code base on a Macbook Pro and it took maybe 10+ minutes on my only attempt. I had to cancel it b/c my laptop was going into "jet" mode w/ the noise levels during a conference call. I'm going to try and compile it again and see how long it really takes for me.

10 minutes? Wow! It's probably due to the initial gradle build.

On my laptop, after a new "git clone", the whole build takes 18s for me.

If I use the prebuilt server (https://github.com/Genymobile/scrcpy#prebuilt-server), so that it only compiles the client, it takes 0.8s.

Would have been awesome like a year and a half ago when I cracked my phone screen.

I can see android users using it in place of an emulator. From what I've heard (I'm not an Android dev) the emulators are generally pretty slow and using a device is way faster.

This would let you control it right from your computer, instead of having to actually tap on your phone, which can be tedious, especially when typing.

While the modern Android emulator is nowdays actually faster than devices, testing on the actual hardware is still important due to device-specific issues.

And having such tool makes this way easier since you don't have to constantly reach for a phone and be wrapped in cables :)

Wireless ADB exists, but the initial APK upload is still pretty slow (compared to wired)

I'm getting just old enough that my near vision is starting to fail. It'd be nice to be able to use my mouse and a computer screen, with a slightly enlarged Android display, to control games and such on my phone.

And since it apparently handles keyboard support, typing on the phone would be a lot easier, too.

Could this be used like a poor man's personal hotspot, when data providers refuse to allow tethering?

I can also see a use for it, where your IM application of choice does not have web/desktop equivalent, but you want to chat via your PC anyway.

If it could control the phone through the network allowing to simulate swiping with the mouse it would be even more useful. As an example, I'm allergic to Whatsapp but am forced to keep it in (on a tablet which stays at home 24/7, data plan only SIM) because of a handful of friends who refuse to use more advanced IM software, so when I'm away they cannot contact me. The WA web app is a joke and forces one to keep the phone/tablet at hand anyway, so although I don't miss Whatsapp at all, being able to tunnel the access to it could be useful sometimes.

Would be neat to launch a SaaS service with it that let people test their apps on various real phones.

Or have "real world device" testing in your CI/CD pipeline.

Or to automate something else that's only available via an android app.

Add Google's: https://firebase.google.com/docs/test-lab/

And Geny's: https://www.genymotion.com/cloud/ (albeit a bit different)

Note that Genymobile/Genymotion is the company which open sources scrcpy ;-)

I know, which is why I couldn't forget it :-)

A consumer use would be a reliable way to do screen capture (e.g. Tinder, Snapchat).

For devs, you could setup a device somewhere for automated testing.

It won't work on apps that block screenshots. For example, when I open my banking apps, I just see a black screen. See https://github.com/Genymobile/scrcpy/issues/36

This opens up the possibility of making something akin to niffy [1], which offers a sane/easy way to automate UI testing. Unfortunately, in the case of Android apps you wouldn't have css selectors to simplify simulation of clicks on specific elements.

1: https://github.com/segmentio/niffy

> Unfortunately, in the case of Android apps you wouldn't have css selectors to simplify simulation of clicks on specific elements.

There is UIAutomator, you can select components based on text, class, index, etc. https://developer.android.com/training/testing/ui-automator....

We use it to automate actions to configure Android devices (when there is no better way).

Why would you need a "real" phone for UI testing? Android has a very good emulator available.

Hey, thank you for such an useful tool! :)

I'm an Android dev currently working on a team using NativeScript. My coworkers' latops have only 4GB RAM and they are unable to use an AVD for development. From now we are going to use scrpy :)

I have 16GB and I can barely use AVD, it's still laggy and terrible compared to the iOS simulator.

EDIT: yes, I do have hardware acceleration enabled.

Awesome tool, and a very good write-up! Wish I was still actively developing for Android, this would be very useful.

This link should be a "Show HN"? I.e. it is about a tool you wrote.

In Show HN rules: https://news.ycombinator.com/showhn.html

> Blog posts […] can't be Show HNs.

Could simply link to their github https://github.com/Genymobile/scrcpy/

Very clever, and nice writeup! A few years ago I wrote a bunch of bash scripts to control my phone over adb (found it useful to script certain things and write messages etc. Before things like WhatsApp had a Web client). This has taken that concept to its most elegant formulation! Well done.

This is amazing - something that the Android team should definitely have supported already..

Great work!

Looks great. It certainly has become much easier to build such apps on modern Android :)

For something a bit more old school, I’d like to insert a shameless plug here that we open sourced something similar several years ago. It’s focused on the enterprise side, so setting it up is unfortunately quite a bit more involved. Screen rendering is obviously far less advanced as well, though still decent enough. It’s compatible with (almost) all Android versions since 2.3 which has its own fun challenges!

Anyway, great project with a modern take!


AFAIK, till now the only alternative for the features mentioned in OP was Vysor by clockworkmod which is a monthly paid app. I had to subscribe it for occasional demos, I'll be happy if Scrcpy fills in the role.

>$2.50/mo, $10/yr, or $40/lifetime. Purchase available in app.

Very nice! We’d be interested in adding VNC support so that we can control Android devices remotely via VNC.

This is awesome, worked perfectly.

Only downside is if you have swipe to unlock, I couldn't actually get the swipe up to trigger the password input screen.

I had this problem with another Android-on-PC app but it turns out I just wasn't click-and-dragging fast enough.

swipe to unlock works for me too.. great app

Been wanting an application like this for quite a long time, no wireless, no 3rd parties, just me, my usb and not requiring java :)

Awesome, I've been using Vysor for this but it def has issues the least of which is the ads, so I can't wait to try this!

MyPhoneExplorer and Samsung SideSync on Windows/macOS had this for a few years now. Glad to see an application for Linux now.

Vysor [1] has been around for a while. Does this improve upon the concept?

[1] https://www.vysor.io/

Its kind of the same thing, Vysor has ads in it though and isn't open source. So this seems like an improvement in general as it doesn't have ads and its open sourced.

Vysor's client is electron. Scrcpy's client appears to be a native executable.

You can also control it wirelessly using adb tcp mode.

Run adb tcpip 5555 and connect it using adb connect command

Actually, it won't work with the current version because of an adb bug ("adb reverse" does not work over "adb connect"): https://issuetracker.google.com/issues/37066218

The solution would be to change the direction of the connection, and use "adb forward", but then scrcpy would try to connect before the server is started, so it would need to retry until connected (and the error would not be noticed on connect, but on first read, due to the tunnel).

Working over "adb connect" would be good, though.

Rather than control with mouse and keyboard I want to control the android purely with voice.

I could see someone taking a bunch of android devices and using this to farm stuff.

This is a really nice tool for the development of headless Android device.

Great info on how it all works. Thanks for that!

Is there X Windows support in Android?

Thank you

Amazing job! Congrats :)

thanks for sharing - this can replace airdroid for me

This is amazing.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact