How to code in Android Studio from any device with JetBrains Projector

JetBrains is the company behind some of the more popular IDEs, including IntelliJ IDEA, PyCharm, and PhpStorm. Even Android Studio, a sort of Google’s internal IDE for Android development, is based on IntelliJ.

While IntelliJ’s IDEs are popular for a reason (they are Well), they can sometimes be a bit heavy. IntelliJ and Android Studio can take a lot of resources just being open, for example. And if you compile something, they’ll use some more. You also can’t (yet) really run JetBrains stuff on mobile devices, as JetBrains doesn’t have easily accessible ARM builds.

So what if you don’t have a powerful computer, or if you don’t even have a computer? Normally this would be where you would look for other IDEs that work on ARM. But JetBrains sort of has a solution, and it’s called the JetBrains Projector.

What is a projector?

You’ve probably heard of Remote Desktop or VNC before. It allows you to interact graphically with a computer on a local network or even on the Internet. JetBrains Projector works much like a remote desktop, but without some of the downsides.

To use JetBrains Projector, you need a computer somewhere on the Internet to host it. This can be an AWS instance or a home server. You can then sign in to it from any supported browser, including Chrome mobile and Firefox.

But instead of displaying an entire desktop and sending a video stream of it to a connected client, JetBrains Projector sends the information necessary to the client to display an IDE as if it is displayed locally. This means there is no compression or resolution scaling, so the IDE seems almost native.

Moreover, JetBrains Projector is not limited to only official JetBrains IDEs. As long as you have an IDE that is closely based on JetBrains, you can use it with JetBrains Projector. This includes Android Studio.

Why a projector?

The main reason you might want to do remote development is what I talked about in the introduction: what if you don’t have a powerful x86-based computer? You can buy a semi-powerful one specifically for development work, or you can build a cloud server and use JetBrains Projector.

This can also be useful if you just want to offload resource requirements. For example, I have a fairly powerful gaming laptop with an i7-9750H and 32GB of RAM. It is more than sufficient even for the large projects that I deal with. But if I want to do something else besides the resource-intensive development, like watch youtube, play a game? Then things start to fall apart.

But I have a Ryzen 7 5800X server with 32GB RAM. So I installed JetBrains Projector on it. Now I can just open a new Chrome window and log into it from my laptop without worrying about juggling resources. The server is also building a lot faster than my laptop, so it’s a win-win situation.

How to use a projector?

JetBrains Projector is intended to be hosted on a Linux machine. That doesn’t mean you can’t run it on macOS or Windows with WSL, but you might run into some weird issues because of it.

To set it up, all you need to do is go to the Projector Installer GitHub repository and follow the instructions there. They will walk you through installing dependencies and setting up an IDE. There are even WSL troubleshooting steps if you need them.

Then you can just connect to your server address using the correct port and token (if you’ve set one), and now you have an IDE running on your device without any overhead.

Android Development

I’m an Android developer, so while I can use IntelliJ IDEA for development, Android Studio tends to perform better. While JetBrains Projector supports third-party IDEs, it’s now just as easy to use the built-in CLI to download and install them. It’s still quite simple.

To use Android Studio with JetBrains Projector, all you need to do is download and extract Android Studio to a reasonable location. Then you can manually add it to the projector via the command line by specifying the path.

There is also another problem with Android and Projector development: running apps. Without anything more, you can code apps and view previews in Projector, but you can’t use an emulator or connect to a real device to run and debug apps. Or can you?

It’s almost as if Google expects this kind of scenario to happen because ADB can connect to a remote server over the internet. All you need is an SSH tunnel from the client to the projector server. I configured Android Studio on the projector to not try to handle ADB and use port 5038. Then I just use some sort of SSH client (OpenSSH, plink, etc.) to create a tunnel that forwards the ADB server run locally on port 5037 to the server on port 5038. Easy!

An SSH and X tunnel for the JetBrains projector

All you need is an SSH tunnel for proper Android development.

If you want more details on how to get Android Studio and the SSH tunnel to work, check out this GitHub document from Joaquim Verges.

A note about Android Studio and other JetBrains based third party IDEs: you cannot update them from the projector screen. You will need to connect directly to the server and update them from there. Make sure that the corresponding Projector instance is stopped before doing this.

Android Development

Since JetBrains Projector runs in a browser and you can log in from something like an Android phone, as a completely random example, I wanted to try something.

Android 11 introduced the ability to enable wireless ADB directly from the device. Although some manufacturers have exposed the setting before this date, it is not available for all Google Certified devices as long as they are on Android 11 or later. Although wireless debugging is intended for use from a computer, it does not have to be.

Applications like Shizuku demonstrate that it is possible on Android 11 to connect with ADB to your device… from your device, without even thinking about using a computer. While Shizuku uses it to allow apps to perform high operations, I think you can probably see where it’s going.

So I created an application! I don’t know if I’ll ever make it public, but it’s pretty straightforward. I have an SSH library with an ARM64 ADB binary. I use the ADB binary to connect to the device I am using, then I use the SSH library to create a transfer tunnel from my device to the projector server. And finally, I use it to store and launch projector URLs.

Bam, develop for Android… from Android! Whenever I’m not at home but want to work on Android development, I can just take out my Samsung Galaxy Tab S7. I have a bluetooth keyboard and bluetooth mouse (note: if you are using Projector, you really want to use a mouse or trackpad. It doesn’t work well with touch input), so I can develop and debug without having to switch devices and without having to lug around a much heavier laptop.

Problems

The JetBrains projector is still in fairly early development, so it’s not perfect.

  1. Sometimes it’s a bit slow when responding to things like scrolling and sliding, and the controls can get wobbly.
  2. Randomly, when viewing the library code (either decompiled or in the source view), the font weight gets really heavy and everything lags behind. This may have been fixed at the time of writing this, however.
  3. Some plugins will not work properly. Since this is not a direct video feed, plugins like built-in browsers simply won’t display anything.
  4. There is no X server support, and there probably won’t be. This can make it difficult to develop desktop and browser apps, but you can still use an SSH tunnel with X forwarding and a local X server if you really need to.
  5. Sometimes the interface crashes and you have to refresh the page or even restart the server service to get it working again.

And there’s more.

But is all of this a dealbreaker? Certainly not for me. I’m doing perfectly fine with a slightly less polished experience (I use Android Studio Canary, after all), especially if that means I can offload all the build work to another computer and even develop for my tablet from my tablet. .

Android Studio running on a Samsung Galaxy Tab S7 via the JetBrains projector


Even with its issues, I still really like JetBrains Projector. It makes development from mobile possible, it shifts the resource load from a local computer to a remote computer, and it’s also really cool.

I know other IDEs like Visual Studio allow you to unload the compilation to a remote machine, but it still requires the IDE to be installed and running locally.

Personally, I’m really excited to see where the JetBrains projector is going because it’s already pretty amazing right now. Hopefully they’ll be able to fix some of the issues I described above, but even now Projector should be safe to use for production-ready projects.

If you would like to try the JetBrains projector for yourself, again here is the link to the installer and initial setup guide. If you want to set up Android Studio in Projector, here is this link again.



Source link

Comments are closed.