Node.js & Android

1. Build Node.js for Android

Linux build environment

jiangling@young:~/node/deps/npm$ uname -a
Linux young 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

32-bit Android NDK

drwxr-xr-x 10 jiangling jiangling      4096  3月  1  2014 android-ndk-r9d

Clone Node.js

git clone https://github.com/joyent/node.git

Android-configure patch

jiangling@young:~/node$ git diff
diff --git a/android-configure b/android-configure
index 7acb7f3..aae0bf1 100755
--- a/android-configure
+++ b/android-configure
@@ -3,7 +3,7 @@
 export TOOLCHAIN=$PWD/android-toolchain
 mkdir -p $TOOLCHAIN
 $1/build/tools/make-standalone-toolchain.sh \
-    --toolchain=arm-linux-androideabi-4.7 \
+    --toolchain=arm-linux-androideabi-4.8 \
     --arch=arm \
     --install-dir=$TOOLCHAIN \
     --platform=android-9

Otherwise, the error arm-linux-androideabi-gcc not found will occur.

Configure && make

Node binary size

Size after configuring without-ssl

2. Run Node.js on Android

I chose a rooted Xiaomi M1 phone and installed "Swiss Army Knife" busyboxarrow-up-right to view system information.

Use ADB to push node and test.js (the classic hello world) to M1:

Run and result 360_1126_10_38_01 360_1125_16_29_01

Last updated