Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install Visual Studio Code (actually code-server) on Android
  1. Install Termux, an Android terminal emulator that provides a Linux execution environment and various tools.

  2. Update system packages in Termux:

    $ pkg update -y
  3. Install dependencies, including python, nodejs, and yarn:

    $ pkg install -y python nodejs yarn git
  4. 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
  5. 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/
  6. 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
  7. Open binding.gyp and enter edit mode. You can do this by pressing i once you open the file using Vim:

    $ vim binding.gyp
  8. 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"
            ],
  9. Save the file and quit text editor. You can do this by pressing ESC and then wq in Vim:

  10. Recompile spdlog using the following command:

    $ npm install
  11. (Optional) To see if spdlog works, run:

    $ npm test
  12. 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) .
  13. Finally, change the working directory back to home and start code-server with the following command:

    $ cd ~
    $ code-server --auth none --disable-telemetry
  14. Now, you can open your browser and visit code-server at http://localhost:8080.

  15. (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
@0R1-qt

This comment has been minimized.

Copy link

@0R1-qt 0R1-qt commented Feb 1, 2021

why is it ~/.config/yarn/global/node_modules/code-server/lib/vscode/node_modules/spdlog/------the second node_modules is missing, how to fix it?

@0R1-qt

This comment has been minimized.

Copy link

@0R1-qt 0R1-qt commented Feb 1, 2021

look at this
@0R1-qt

This comment has been minimized.

Copy link

@0R1-qt 0R1-qt commented Feb 1, 2021

should i creat node_modules manually?

@ppoffice

This comment has been minimized.

Copy link
Owner Author

@ppoffice ppoffice commented Feb 1, 2021

@0R1-qt No. It is created by yarn global add code-server.

What version of code-server are you using? Maybe they removed spdlog from the dependency list. You can also try to skip step 5 to 11 to see if it works.

Update
Please install git using pkg install git and reinstall code-server.

@0R1-qt

This comment has been minimized.

Copy link

@0R1-qt 0R1-qt commented Feb 3, 2021

Will it gonna have an node_modules folder if I'm going to install git?

@0R1-qt

This comment has been minimized.

Copy link

@0R1-qt 0R1-qt commented Feb 5, 2021

I fix it but icanttrub python programs

@myPyDev

This comment has been minimized.

Copy link

@myPyDev myPyDev commented Feb 22, 2021

pkg install python then
pip install virtualenv
termux-setup-stprage
virtualenv venv -p python
source venv/bin/activate

@n-ce

This comment has been minimized.

Copy link

@n-ce n-ce commented Feb 27, 2021

There is no spdlog folder in 3.9.0, so I skipped to 11th step and its giving error 500 in browser

@ppoffice

This comment has been minimized.

Copy link
Owner Author

@ppoffice ppoffice commented Mar 6, 2021

@n-ce Are you sure your installation is complete? I just tried to install code-server 3.9.0 on Android 11 using the exact steps as above and it worked. The spdlog is still a dependency of vscode and it should appear in the node_modules folder. Please reset Termux and try again.

@Kuchiriel

This comment has been minimized.

Copy link

@Kuchiriel Kuchiriel commented Mar 22, 2021

This should have a comma after [ "-latomic" ]

"targets": [{
        "target_name": "spdlog",
+       "libraries": [ "-latomic" ],
        "sources": [
                "src/main.cc",
                "src/logger.cc"
        ],
@tfkhdyt

This comment has been minimized.

Copy link

@tfkhdyt tfkhdyt commented Mar 27, 2021

How to fix this?
@GiancarloAparicio

This comment has been minimized.

Copy link

@GiancarloAparicio GiancarloAparicio commented May 16, 2021

It works perfect without errors, thanks for the guide :)

@Jagaadaku

This comment has been minimized.

Copy link

@Jagaadaku Jagaadaku commented Jun 18, 2021

Vs code was running yesterday properly but today 127.0.0.1 site is not opening was may be the possible cause.

@mahaveerr

This comment has been minimized.

Copy link

@mahaveerr mahaveerr commented Jun 24, 2021

I am getting this problem in android redmi phone
Uploading IMG_20210625_040748.jpg…

@mahaveerr

This comment has been minimized.

Copy link

@mahaveerr mahaveerr commented Jun 24, 2021

When i went to local server it shows me this
Uploading Screenshot_2021-06-25-04-16-11-406_com.android.chrome.jpg…

@Python2122

This comment has been minimized.

Copy link

@Python2122 Python2122 commented Jun 27, 2021

How much space is required ?

@n-ce

This comment has been minimized.

Copy link

@n-ce n-ce commented Jun 29, 2021

@Python2122 over 1GB.

@Pintusera

This comment has been minimized.

Copy link

@Pintusera Pintusera commented Sep 16, 2021

'~/.config/yarn/global/node_modules/code-serve '

There no folder name in 'lib'

@shivahuh1

This comment has been minimized.

Copy link

@shivahuh1 shivahuh1 commented Sep 22, 2021

Screenshot_20210922-225614

Why is this happening to me?

@9yaskhan

This comment has been minimized.

Copy link

@9yaskhan 9yaskhan commented Sep 26, 2021

Screenshot_20210922-225614

Why is this happening to me?

Run this👇
yarn config set ignore-engines true

@unbhopper

This comment has been minimized.

Copy link

@unbhopper unbhopper commented Oct 11, 2021

Screenshot_20210922-225614
Why is this happening to me?

Run this👇 yarn config set ignore-engines true

This not working. Command pkg install nodejs setup version 16.x, but VS code need 14.x. That fixes by
pkg remove nodejs
pkg install nodejs-lts

@unbhopper

This comment has been minimized.

Copy link

@unbhopper unbhopper commented Oct 11, 2021

but i cant download any extension

@Gunloverit

This comment has been minimized.

Copy link

@Gunloverit Gunloverit commented Oct 11, 2021

Op

@Gunloverit

This comment has been minimized.

Copy link

@Gunloverit Gunloverit commented Oct 11, 2021

Op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment