Make sure you have adb
installed and that it works. Test this by connecting your phone and running adb devices
. In order to proceed past the build stage, your device must be rooted. The device I used is running Cyanogenmod with root enabled for both apps and adb.
You'll need to get the Android NDK. I used r8e, which you can get from here: http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86.tar.bz2. Make sure you get the x86 version, as the x86_64 version will not help you. Let's call the path where you unpack this NDK_PATH.
git clone https://github.com/joyent/node.git
We'll refer to the local path as NODE_SOURCE.
Apply the following changes (either by hand or using patch
):
diff --git a/common.gypi b/common.gypi
index 42ab572..48334de 100644
--- a/common.gypi
+++ b/common.gypi
@@ -10,7 +10,8 @@
'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way
'gcc_version%': 'unknown',
'clang%': 0,
- 'python%': 'python',
+ 'python%': 'python2',
+ 'arm_version%': 7,
# Enable V8's post-mortem debugging only on unix flavors.
'conditions': [
./android-configure NDK_PATH
make
You can find the binary image at NODE_SOURCE/out/Release/node
. This is the file you will copy to your Android device.
At this point, you have a binary node
that will run on your Android device. There are a few steps involved in getting this file to your device.
With your device connected to your computer, run
adb push NODE_SOURCE/out/Release/node /sdcard/
adb shell
su
mount -o remount,rw /
cp /sdcard/node /sbin
chmod 755 /sbin/node
chmod 755 /sbin
node
I am looking at the possibility of compiling node.js for Android so I can embed node.js in my app, in order to avoid the need to port a large codebase from node.js/javascript to Android/Java. What I'm not following is why the device needs to be rooted (not an option for embedding it in an app) or how this approach fits into the notion of embedding node.js directly in an app.