Using Visual Studio Code for Android Development

Hafiz Pariabi
4 min readOct 22, 2020

--

First, why do you event want to do this when Android Studio is already a fully capable IDE available on all platforms. Here’s some reason :

To do realtime remote pair-programming session with actual collaborative-editing and shared build/test. This is something you cannot do (yet) with Android Studio. On the other hand, VSCode has a great support for it through Live Share Extension. So, being able to work with your project in VSCode automatically give you that capability.

More lightweight, casual use case. Android Studio, with IntelliJ being its base, is notoriously heavy. That is fine if you are in the development mode where you need many of all its integrated capability. However, there is a case, like where you are mostly working with more internal and logic code with less need of UI matter, you need only very common tooling related to unit-test, code, refactor cycle. On the later case, VSCode has much all you need without being as resource-demanding and you can launch and work more conveniently.

That just some major ones of the reason you might want to set it up. There are some other benefits that also interesting to look at. Like, getting access to rich VSCode extension ecosystem. As like Live Share extension mentioned above, you can also make use of some other interesting extensions like GitLens where you have rich git-related annotations right on the editor or Todo+ which is quite fun and geeky way to track your ever-growing task while you code with nothing but text file.

Complementary Nature

This surely not meant to actually replace Android Studio as your main IDE but to complement it instead. A way of adding capabilities that you need that is not available on it natively. Beyond what you need from VSCode specifically above, like doing remote pairing for example, you’d better use Android Studio for the rest.

So, feel free to stick with Android Studio and only pickup VSCode for those rare times you actually need to.

The Setup

Beyond the base VSCode install, here are some extension you need to install :

  • Kotlin. This add the typical language support like syntax highlighting and formatting. There is extension that is already exist longer with more install number related to Kotlin but I find this one has more feature and already a good amount of installs
  • Gradle Language Support. For Graddle support, obviously
  • Gradle Task. This one is the interesting one. As we’ll see later, this makes working with Android project can still be quite convenient even though we are outside Android Studio with all its various shortcuts and automation

Apart from that you can install other extension based on your specific needs like LiveShare mentioned above if you meant to do remote pair programming with it, or install vim editing support if you are into it.

Gradle Pinned Task

With Gradle Task you’ll get access to gradle tasks as a nice navigable tasks on the sidebar. That is already interesting in itself but what is even more useful is that you can pinned the task you often need to the Pinned Task section as highlighted on the screenshot below, a kind of favorite list, complete with saved custom arguments that you want to pass to it.

This makes accessing any repeated command very convenient and fast.

Understand Command Line Counterpart of IDE Interface

Directly calling gradle task as above means you need to get familiar with the command line counter part of the action you usually do through Android Studio interface like from buttons or shortcuts. The below resources could help to map it out. As a side benefit, you’ll gain more knowledge of the platform itself in the process.

After you know the command line you can use directly it on the built-in terminal or setup a Gradle Pinned Tasks as mentioned above.

Below is the example of the task run on the built-in terminal.

The good thing about it is run in such a direct manner on just the terminal means your remote pair, if you use Live Share, will have access to the same command and terminal also. This means you can switch who drives the pairing session, for both editing and running the test, at any time instantly.

So, that’s it, it is a relatively simple setup for quite a number of useful features, especially if you in need for the things that it provides like real time collaborative editing/running.

--

--