Install Visual Studio Code (actually code-server) on Android
===============================
Install Termux, an Android terminal emulator that provides a Linux execution
environment and various tools.
Update system packages in Termux:
$ pkg update -y
Install dependencies, including python, nodejs, and yarn:
$ pkg install -y python nodejs yarn git
Install code-server, an adaptation of Visual Studio Code that runs as a web app
using the following command. The installation may take a while:
$ yarn global add code-server
Before starting code-server, we are going to fix an error caused by spdlog, which
is a dependency of Visual Studio Code. First, change your working directory to
~/.config/yarn/global/node_modules/code-server/lib/vscode/node_modules/spdlog/:
$ cd ~/.config/yarn/global/node_modules/code-server/lib/vscode/node_modules/spdlog/
You will need a text editor for the next step. Here Vim is used for this task, but
you are free to use whatever text editor you love:
$ pkg install vim
Open binding.gyp and enter edit mode. You can do this by pressing i once you open
the file using Vim:
$ vim binding.gyp
Add "libraries": [ "-latomic" ] below "target_name": "spdlog",. This helps spdlog
compile on Android.
"targets": [{
"target_name": "spdlog",
+ "libraries": [ "-latomic" ],
"sources": [
"src/main.cc",
"src/logger.cc"
],
Save the file and quit text editor. You can do this by pressing ESC and then wq in
Vim:
Recompile spdlog using the following command:
$ npm install
(Optional) To see if spdlog works, run:
$ npm test
To fix the file search function of code-server, install ripgrep via pkg and link it
to the correct place:
$ pkg install ripgrep -y
$ cd ~/.config/yarn/global/node_modules/code-server/lib/vscode/node_modules/vscode-
ripgrep/bin
$ ln -s $(which rg) .
Finally, change the working directory back to home and start code-server with the
following command:
$ cd ~
$ code-server --auth none --disable-telemetry
Now, you can open your browser and visit code-server at http://localhost:8080.
(Bonus) If you wish to visit this code-server from another device in the same local
network, you can expose the HTTP service to all network interfaces by starting
code-server with --bind-addr:
$ code-server --bind-addr 0.0.0.0:8080 --disable-telemetry
You can find the password under ~/.config/code-server/config.yaml:
$ cat ~/.config/code-server/config.yaml
You may also need to enable HTTPS to enable clipboard and others features of Visual
Studio Code in browsers. To do this, install openssl-tool and let code-server
generate a certificate on startup:
$ pkg install openssl-tool
$ code-server --bind-addr 0.0.0.0:8080 --cert --disable-telemetry
You can get the public IP address of your device using the command below in Termux:
$ ifconfig