Skip to main content

Running VS Code on an Android Device

IF you're the sort of person who's phone is their workhorse as I am, then finding a decent IDE for quick edits on code is while a personal choice a bit of a problem as there are not many out there.

While i'm not advocating trying to do all your coding on a phone,having access to a familiar interface would make things useful.

With its library of plugins and easy to use interface VSCode is the defacto standard for nany when editing code such as ansible, bash or python. While its not supported as an app on android it is possible with a little tinkering to get it working on your phone.

Termux

Termux

Termux is a Terminal emulator for Android which doesn't require root, its available on either the Google Play store or fDroid for download. Once installed you get a local terminal which can run bash, fish, zsh or others and the same tools you use on Linux desktops like ssh, nano, rsync and grep are all available and there is a package management system to pull in other applications

Install Termux

First step is to install Termux from either the Google Play stor of FDroid and launch the application. This will take you to a command prompt.

Install Termux Files

Once installed we need to update the system and install some key files

Update termux:

apt-get update && apt-get upgrade -y

Install wget:

apt-get install wget -y

Install proot:

apt-get install proot -y

Install git:

apt-get install git -y

Go to HOME folder:

cd ~

IF this all went forward ok, we are now ready to install Ubuntu onto the app.

Install Ubuntu on Termux

MFD Gaming has a script which will do the heavy lifting for this and install Ubuntu 20.10 (at time of writing) into Termux (Link Below)

Download script:

git clone https://github.com/MFDGaming/ubuntu-in-termux.git

Go to script folder:

cd ubuntu-in-termux

Give execution permission:

chmod +x ubuntu.sh

Run the script:

./ubuntu.sh -y

Now just start ubuntu:

./startubuntu.sh

Update Ubuntu

apt update 

apt upgrade

Install Wget

apt install wget

VSCode

Install VSCode on Termux

Now Ubuntu is running in Termux the next step is to install the ARM version of VS Code into the Termux environment

wget https://github.com/cdr/code-server/releases/download/v3.7.1/code-server-3.7.1-linux-arm64.tar.gz
Note: To Find the latest version please look at
Releases · cdr/code-server
VS Code in the browser. Contribute to cdr/code-server development by creating an account on GitHub.
tar -xvf ./code-server-3.7.1-linux-arm64.tar.gz
rm ./code-server-3.7.1-linux-arm64.tar.gz
cp -r code-server-3.7.1-linux-arm64 /lib/
ln -s /lib/code-server-3.7.1-linux-arm64/code-server /bin/

Open VSCode on your mobile

Having Installed vscode you can now run the server

code-server 

Copy the passcode it generates as you'll need this to login later

Alternative method for getting password

tail ~/.config/code-server/config.yaml

Open in Browser on Android Device

localhost:8080 

in the browser and paste the passcode generated in the terminal

In summary

The reality is i'd suggest that unless you're running this on a Linux Tablet then really its a bit too fiddly to use as a daily driver however it is a good guide for seeing the power of Termux and what you could do with it.


Comments

Popular posts from this blog

How to use Django Bootstrap Modal Forms

Everything you need to know when developing an on demand service app

Documentation is Very vital before you develop any system or app