Install VS Code in an Android Phone?
Tags: beginners, vscode, tutorial, productivity
Published: 2023-09-03 16:48:02

If you  wants to code on your Android device using VS Code, this might be the best setup for you.

Follow the steps below:

## Step 1 - Install termux
In order to install VS code, you will have to install the Termux app by scrolling down and downloading apk [using this link from f-droid](https://f-droid.org/en/packages/com.termux/).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vwhlp1brlgrwl9f0boqc.png)

The official release available on the play store doesn't seem to get the packages updated for some reason. 

Termux from Play Store won't work. This is what the official Termux Github repository has to say:

 

"Termux and its plugins are no longer updated on Google Play Store due to Android 10 issues and have been deprecated. The last version released for Android >= 7 was v0.101. It is highly recommended to not install Termux apps from Play Store anymore."

 

Open the downloaded apk by clicking "Open"


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3nqafasr40fgssglq29.png)

Now Install the apk file. If you are prompted to go to settings and enable installation of Apps from unknown sources, do that!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7emx22ydeoge8hlpwaei.png)

Open the Termux app and you will see a screen like this:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n6iu2773uax8sskou7zj.png)

## Step 2 - Install Ubuntu using Termux

Enter the following command on Termux to update the package repository

```
pkg update
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oker3y510lb9ccxp5tpw.png)

When prompted, press 'y' and then press enter. You will have to press y followed by enter every time you are prompted for it.

Now let's upgrade the packages using the below command in Termux

```
pkg upgrade
```
Now let's install proot-distro using the following command:

```
pkg install proot-distro
```
Now let's list all the distros we can install using proot using the following command (This command is optional)

```
proot-distro list
```
You will see a screen like this: 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7behqupglezy5c6t9rjz.png)


Now fire this command and Ubuntu will start to install on your Android phone

```
proot-distro install ubuntu
```
Ubuntu will start installing and you will see a screen like this:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rmtu74i1js8n8fpwrioh.png)

Now, start Ubuntu by firing the following command:

```
proot-distro login ubuntu
```

You will now see a root@ubuntu prompt in the terminal like this:



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50i7vcwmb7v5mnap9p1p.png)


## Step 3 - Downloading code server

While on Ubuntu run the following command:

```
apt update
```
and following command to upgrade the package repository:
```
apt upgrade
```
Press 'y' and enter whenever prompted.

Now install wget using the following command:
```
apt install wget
```
Again press 'y' and enter whenever prompted to confirm the installation. You now have wget installed!

We will now download the latest release of the code server from Github using the following command:

```
wget https://github.com/coder/code-server/releases/download/v4.16.1/code-server-4.16.1-linux-arm64.tar.gz
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n8yfgt7fej9dzkvoinuh.png)

Extract the tarball using the following command:

```
tar -xvf ./code-server-4.16.1-linux-arm64.tar.gz
```
The tarball will start extracting. Wait for the tarball extraction to finish


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmzmax5000rr79mwrauy.png)

Enter the /bin folder of your code-server installation on Ubuntu (running on your phone)

```
cd code-server-4.16.1-linux-arm64
cd bin
```
## Step 4 - Set up a password and start using VS Code
Setup a password for your VS Code instance using the following command:


```
export PASSWORD="password"
```
Note: I am using a very weak password for demonstration purposes as I will use this code-server locally on my phone. Consider using strong passwords for your serious projects

Launch the code server using the following command:

```
./code-server
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sm1wu2ho6wmwnclpmu2x.png)

Now go to your browser. I am using Google Chrome for Android and go to localhost:8080

You will finally see a screen like this:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/byanfkogig4zuc0iu9ni.png)
After entering the password you will see a welcome screen like this:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q2rxf0s6f0277w9xbhj0.png)
You can now start coding in VS Code on your Android Devices


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlnrk2cd6wp4ogm397gj.png)



Hope that worked for your phone. Please share your experiences, ask questions, or suggest improvements in the comments section. Happy Hacking!
### Alternative
You can use vscode directly by visiting [vscode.dev](https://vscode.dev/) in your browser.

Caveats:
1. If the update command doesn't work on your Termux or you get some other network errors, try to change the default repo by using the command below:
```
termux-change-repo
```
Change the repository to Mirror by Grimle and try the pkg update command again. It should work!

2. Whenever prompted, press 'y' and then press enter. You will have to press y followed by enter every time you are prompted for it.