Top Ad unit 728 × 90

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

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

While IntelliJ’s IDEs are popular for a reason (they’re good), they can be a little heavy at times. IntelliJ and Android Studio can take up a lot of resources just by being open, for instance. And if you’re compiling something, they’re going to use even more. You also can’t (yet) really run JetBrains stuff on mobile devices, since JetBrains doesn’t have easily-accessible ARM builds.

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

What is a projector?

You’ve probably heard of remote desktop or VNC before. It lets you interact graphically with a computer over a local network or even the internet. JetBrains Projector works a little like a remote desktop, but without some of the disadvantages.

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

But instead of displaying an entire desktop and sending a video feed of that back to a connected client, JetBrains Projector sends over the information needed for the client to display an IDE as if it were displaying locally. This means there isn’t any compression or resolution scaling, so the IDE looks almost native.

Also, JetBrains Projector isn’t limited to just the official JetBrains IDEs. As long as you have an IDE that’s closely based on one from JetBrains, you can use it with JetBrains Projector. That includes Android Studio.

Why a projector?

The biggest 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 could buy a semi-powerful one specifically for development work, or you could spin up a cloud server and use JetBrains Projector.

It can also be useful if you just want to offload the resource requirements. For instance, I have a pretty powerful gaming laptop with an i7-9750H and 32GB of RAM. That’s plenty for even the large projects I deal with. But if I want to do something else on top of development that’s resource-intensive as well, like watching YouTube, playing a game? Then things start to fall apart.

But I have a Ryzen 7 5800X server with 32GB of RAM in it. So I installed JetBrains Projector on that. Now I can just open a new Chrome window and connect to it from my laptop without worrying about juggling resources. The server also builds much faster than my laptop, so it’s a win-win situation.

How is using a projector?

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

To get it set up, all you need to do is head over to the Projector Installer GitHub repo and follow the instructions there. They’ll walk you through getting the dependencies installed and getting an IDE set up. There are even some WSL troubleshooting steps if you need them.

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

JetBrains Projector running Android Studio in Chrome

Android Development

I’m an Android developer, so while I could use IntelliJ IDEA for development, Android Studio tends to work better. While JetBrains Projector does support third-party IDEs, it’s now as simple as using the built-in command-line interface to download and install them. It’s still pretty simple, though.

To use Android Studio with JetBrains Projector, all you have to do is to download and extract Android Studio somewhere sensible. Then you can manually add it to Projector through the command line by specifying the path.

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

It’s almost like Google expected this sort of scenario to happen because ADB can connect to a remote server over the Internet. All that’s needed is an SSH tunnel from the client to the Projector server. I set Android Studio on the Projector to not try to manage ADB and to use port 5038. Then I just use some sort of SSH client (OpenSSH, plink, etc) to create a tunnel that forwards the ADB server running locally on port 5037 to the server on port 5038. Easy!

An SSH and X tunnel for 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 SSH tunneling working, check out this GitHub document by Joaquim Verges.

One note about Android Studio and other third-party JetBrains-based IDEs: You can’t update them from the Projector screen. You’ll need to remote into the server directly and update them from there. Make sure the corresponding Projector instance is stopped before you do.

Android Android Development

Since JetBrains Projector runs in a browser, and you can connect 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. While some manufacturers exposed the setting before then, it’s not available for all Google-certified devices as long as they’re on Android 11 or later. While wireless debugging is meant to be used from a computer, it doesn’t have to be.

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

So I made an app! I don’t know if I’ll ever make it public, but it’s pretty simple. I’ve got an SSH library in it along with an ARM64 ADB binary. I use the ADB binary to connect to the device I’m using, then I use the SSH library to create a forwarding tunnel from my device to the Projector server. And finally, I use it to store and launch projector URLs.

Bam, developing for Android…from Android! Any time I’m not home but I want to get some Android development work in, I can just take out my Samsung Galaxy Tab S7. I’ve got a Bluetooth keyboard and a Bluetooth mouse (sidenote: if you’re using Projector, you’ll really want to use a mouse or trackpad. It doesn’t do well with touch input), so I can develop and debug without needing to switch devices and without having to lug around a much heavier laptop.

Problems

JetBrains Projector is still in pretty early development, so it’s not perfect.

  1. Sometimes it’s a little laggy when responding to things like scrolling and dragging, and controls can go wonky.
  2. Randomly, when viewing library code (either decompiled or in source view), the font weight gets really heavy and everything lags. This may have been fixed as of writing this, though.
  3. Some plugins won’t work properly. Since this isn’t a direct video stream, plugins like the embedded browsers just won’t display anything.
  4. There’s no X server support, and there probably won’t be any. This can make developing desktop and browser apps tricky, but you can always use an SSH tunnel with X forwarding and a local X server if you really need it.
  5. Sometimes the interface locks up and you need to refresh the page or even restart the server service to get it to work again.

And there’s more.

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

Android Studio running on a Samsung Galaxy Tab S7 via JetBrains Projector


Even with its problems, I still really like JetBrains Projector. It makes developing from mobile possible, it moves resource load from a local computer to a remote one, and it’s also just really cool.

I know other IDEs, like Visual Studio, let you offload compilation to a remote computer, but that still requires you to have the IDE installed and running locally.

I’m personally really excited to see where JetBrains Projector goes from here because it’s already pretty incredible right now. Hopefully, they’ll be able to fix some of the problems I described above, but even now, Projector should be safe to use for production-ready projects.

If you want to try JetBrains Projector for yourself, here’s the link again to the installer and initial setup guide. If you want to set up Android Studio in Projector, here’s that link again, as well.

The post How to code in Android Studio from any device with JetBrains Projector appeared first on xda-developers.



from xda-developers https://ift.tt/2OwrrUY
via IFTTT
How to code in Android Studio from any device with JetBrains Projector Reviewed by site on 08:55 Rating: 5

No comments:

All Rights Reserved by android central © 2014 - 2015
Powered By Blogger, Designed by Sweetheme

Contact Form

Name

Email *

Message *

Powered by Blogger.