How to Run Android Studio on ANY Device With JetBrains Projector
By: Joaquim Verges
Tags: Development, Android, AndroidDev, Jetbrains, Linux

Of course you would never code on a phone, but it proves that the device hardware is irrelevant. If it has a browser, you can use it to code. This changes everything!

Without the constraints of a beefy hardware, I can choose a development machine that is portable, lightweight, and much cheaper! A good choice in my opinion is a decent Chromebook, a MacBook Air, or a Surface Go. I even considered an iPad as an alternative, it works, but definitely not as comfortable as a real laptop. My personal favorite so far is the Pixelbook Go, great keyboard and super lightweight, been really enjoying coding from it.

Where is Android Studio actually running?

You still need a beefy machine either in the cloud on on your local network to do the actual heavy lifting of running the IDE and Gradle builds. Luckily cloud VMs are now a commodity, and you can get one up and running in a matter of minutes via services like Amazon AWS, Google Cloud or Microsoft Azure. I went with AWS, chose an EC2 instance with 8 cores, 32Gb of RAM and 100 Gb of storage. Running the instance costs me around $0.40 / hour, not cheap if you’re running it 24/7, but since I use it only for a few hours a week for my personal projects, it ends up being quite affordable. Even if I used it for 8 hours a day, 5 days a week, it would cost me around $64 / month. Not bad considering I don’t need an expensive laptop anymore.

When I want to work on my projects, I just start my EC2 instance, run Projector on it, then open a Chrome tab and I’m ready to code. No more crazy fans, no more overheating!

How does it work?

The idea behind Projector is simple but rather brilliant. It intercepts drawing commands from the IDE (or any Swing application) with a custom drawing engine (AWT implementation) that instead of rendering things on screen, records each command, serializes them and sends them to a web client. The web client interprets those drawing commands and renders them in a web page. The web client records keyboard and mouse input, and sends it back to the IDE via AWT.

The beauty of this approach is that even with a slow connection, it renders crisp, pixel-perfect fonts and UI, because it understands the underlying software, so it can render fonts in vector format. Input is also very responsive, because the protocol is specialized, and therefore optimized. This is the killer advantage over more generic remote desktop solutions like VNC, which stream pixels directly. Remote desktops solutions usually render blurry fonts and feel unresponsive over slow connections.

The only drawback from this approach is that some IDE keyboard shortcuts conflict with the browser’s own shortcuts. For instance, cmd+w closes the browser tab instead of one of the tabs in the IDE. There is a work around for that though, by adding the page as a desktop shortcut, which opens any website in app mode. With that, everything has been working really well for me, including all my shortcuts. When putting Chrome in full screen, it pretty much feels like the real thing.

Projector is still very early days, but I can’t wait to see how it evolves.