Hello everyone!
In this tutorial, we will run an Angular Node App (and also a React App) on Android, and host it on localhost by using the Termux app. We will also use the Acode Editor application to browse and easily change our code files. NO ROOT IS NEEDED.
Disclaimer:
- The chances of encountering any issues that may affect your Android device are minimal to none. However, I'm not responsible for any damage, data loss, or malfunction that may occur to your Android device after following this tutorial.
Prerequisites:
- Any Android device running Android 10 and up. In my case I will either use a Lenovo Tab P11 Pro 8GB in Productivity Mode or a Samsung Galaxy S20 FE 6GB in DeX Mode with a Bluetooth Mouse & Keyboard connected
- Termux App from F-Droid - Currently on Version 0.118.0 (118) - Added on 2022-01-11
- Acode Editor App from F-Droid - Currently on Version 1.8.6 (312) - Added on 2023-09-01
Table of Contents:
Installing Termux
First, we need to install Termux (terminal) App from F-Droid * (or from the Termux GitHub Repository). We will not install the Termux from Google Play Store due to lack of updates there.
* Please make sure that you don't press the big blue "Download F-Droid" button as it will download the F-Droid store instead of the Termux App!
Currently latest available version as of now (September 24, 2023) is Termux Version 0.118.0 (118) added on 2022-01-11
Installing apt package manager and other dependencies
Now that we are in the Termux app on our Android device, we can run the following:
- Update and upgrade Termux's
pkg
package manager
pkg update -y
pkg upgrade -y
Note: In Termux you can click and hold to show the copy/paste menu (in order to copy-paste these commands)
- Install
apt
Package Manager as well as updating and upgrading (Note that we add the-y
option to automatically say "yes" to the install when asked)
pkg install apt -y
apt upgrade -y && apt update -y
- Install
openssl-tool
dependency
apt install openssl-tool -y
- Some other packages might come in handy, such as
git
apt install git -y
Installing Nodejs
Now, time to actually install Node.js
- We just need to run:
apt install nodejs
- And check the installed version
node --version
Note: If we want a different version of Node.js
- We can get the apt package for nodejs 16 by running the following and update the apt package manager including this version
curl -sL https://deb.nodesource.com/setup_16.x | bash - apt update
- And then just install it
apt install nodejs node --version
Resource: https://computingforgeeks.com/how-to-install-node-js-on-ubuntu-debian/?expand_article=11
Installing and Running Angular (ng)
Let's install Angular "globally" by running:
npm install -g @angular/cli
ng version
And also let's create a quick demo project:
- First, let's create a separate folder
mkdir projects
cd projects/
- And create a new Angular app within
angularapp
directory
ng new angularapp
cd angularapp/
- Now let's run locally this Angular app. The default Android browser should open to http://localhost:4200/
ng serve --open
Installing Acode Editor App
With Acode App from F-Droid installed, we can now browse through Termux's created directories and files within its emulated storage.
And of course, edit files and see changes in real-time (without refreshing the app).
Installing other packages in Termux
Running React App (npx)
We can also create a React application.
- Just run the following (also write "y" if prompted to install the "create-react-app" package)
npx create-react-app reactapp
cd reactapp
- Then run it on http://localhost:3000/
npm start
Installing Java
As a bonus, we can also install other APT packages such as openjdk to run Java:
- We can search any available packages within APT (compatible with an ARM-based CPU) by running
apt search java
- We see that we can install Java 17 by running
apt install openjdk-17
javac --version
java --version
- Now let's do a quick test
cd projects/
mkdir javaapp && cd javaapp
- By writing a fast hello world example
vi Hello.java
# Note, you can also install vim by running
apt install vim
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
cat Hello.java
- Compile and run
javac Hello.java
java Hello
Conclusions
I wrote this mini tutorial as I didn't see that many quick tutorials on this topic so I thought I should write my own (or at least for my future self).
The little mind-boggling idea is the mobile devices that we use every day (smartphones, tablets) are getting more powerful year by year - e.g. see the performance comparison between Snapdragon 888 (2020) vs Snapdragon 8 Gen 2 (2022) - therefore it feels like those devices aren't used by full their extent.
Performance-wise, mid-range devices (such as Lenovo Tab P11, Samsung Tab S7 FE, Xiaomi Pad 6, or Samsung Galaxy S21 FE) are on pair with budget laptops from around 2020 (at least from the bench scores).
However, the weird part is that I use my budget laptop for multitasking tens of heavy-load applications. On a laptop equipped with a quad-core Intel I5 gen 10 CPU with 16GB of RAM (that scores around 3000 MultiCore points in Geekbench 5) I always have 20-30 Chrome tabs open while running 2 to 3 FullStack Docker Apps (with MySQL/Java/Nodejs and other microservices), while also playing videos in the background and compiling with maven java projects, while also doing some quick edits in Excel (Sheets) or Word (Docs) - and the performance/smoothness is fine (not great, but okay). So why can't we use our mobile devices as well for all these tasks?
Maybe the mobile devices are still early for such tasks and the software is not yet there. Maybe the limiting factor is the different architecture (ARM based on RISC vs. x86 based on CISC), however, Apple's M1/M2 chips might have proved this wrong. Maybe the general public will never use their smart devices for high-load multitasking and productivity work (and only use them for media consumption and fast email/news checking, as these devices were intended).
We will see.
Until then, I hope that this article at least sparked some curiosity!
Have a great day!
Radu
Top comments (1)
One more note: You can also use Kiwi Browser Android App for arm64 to have the Dev Tools panel when testing a web app.