Node.js on Android
2013-03-26 10:32
288 查看
From: http://blog.amt.in/nodejs-on-android
I'm trying to make the recently popular (well, maybe not so recently) Node.js run on Android. So far, I've succeeded
in getting it to run on the ISO1, a smartphone running Android 1.6, but only by doing the following.
Here
are the basic steps:
Root
the IS01
Use
qemu to build a Linux on an ARM environment
Use
the ARM Linux environment to build Node.js
Copy
the Node.js binary to the IS01
This
step requires root permissions on Android to get Node.js running, since we need to create a lib directory in which to place shared libraries.
To
root the device quickly, we'll follow the directions in the MobileHackerz Blog: Getting
Root Permissions for the au IS01, build 01.00.09(Japanese).
Following
the directions there is an easy way to get root.
Things
to watch out for:
Turn
USB debugging on.
Install
ChainsDD Superuser.
Try
repeatedly until it works.
Using
qemu allows us to emulate an ARM CPU, and build a virtual environment. We'll install debian on qemu, and from there build Node.js. This will get us a Node.js binary that can run on an ARM processor.
For
details about building the qemu environment, I used Himajime’s
site for ARM emulation.
The
procedures are as follows. I'm using Ubuntu 10.4.
Install
qemu
Get
and execute the image
Now
we grab the installed Debian image file.
I'm trying to make the recently popular (well, maybe not so recently) Node.js run on Android. So far, I've succeeded
in getting it to run on the ISO1, a smartphone running Android 1.6, but only by doing the following.
Here
are the basic steps:
Root
the IS01
Use
qemu to build a Linux on an ARM environment
Use
the ARM Linux environment to build Node.js
Copy
the Node.js binary to the IS01
Rooting
the IS01
Thisstep requires root permissions on Android to get Node.js running, since we need to create a lib directory in which to place shared libraries.
To
root the device quickly, we'll follow the directions in the MobileHackerz Blog: Getting
Root Permissions for the au IS01, build 01.00.09(Japanese).
Following
the directions there is an easy way to get root.
Things
to watch out for:
Turn
USB debugging on.
Settings => Applications => Development => USB debugging
Install
ChainsDD Superuser.
Install it from the Android Market
Try
repeatedly until it works.
Using
qemu to build Linux on an ARM environment
Usingqemu allows us to emulate an ARM CPU, and build a virtual environment. We'll install debian on qemu, and from there build Node.js. This will get us a Node.js binary that can run on an ARM processor.
For
details about building the qemu environment, I used Himajime’s
site for ARM emulation.
The
procedures are as follows. I'm using Ubuntu 10.4.
Install
qemu
$ sudo apt-get install qemu qemu-kvm-extras
Get
and execute the image
Now
we grab the installed Debian image file.
$ wget http://people.debian.org/~aurel32/qemu/armel/debian_lenny_armel_small.qcow2 $ wget http://people.debian.org/~aurel32/qemu/armel/initrd.img-2.6.26-1-versatile $ wget http://people.debian.org/~aurel32/qemu/armel/vmlinuz-2.6.26-1-versatile[/code]
Run
Debian on qemu
Execute
the following command to start Debian on qemu.$ sudo qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.26-1-versatile -initrd initrd.img-2.6.26-1-versatile -hda debian_lenny_armel_small.qcow2 -append "root=/dev/sda1" -m 256 -redir tcp:2222:10.0.2.15:22 -redir tcp:8124::8124
Keep
the following in mind:
The
above has been formatted to display, but should be executed on one line
Memory
is allocated by specifying -m 256
Connections
via ssh over port 2222 on localhost are enabled by specifying -redir tcp:2222:10.0.2.15:22
Access
over port 8124 is checked by specifying -redir tcp:8124::8124We
Using
the ARM Linux environment to build Node.js
can build Node.js using the usual method. We could also use nave to manage multiple versions of Node.js, or build as-is from the source code.$ sudo apt-get install build-essential libssl-dev curl $ mkdir tmp $ cd tmp $ wget http://nodejs.org/dist/node-v0.3.1.tar.gz $ tar -xvzf node-v0.3.1.tar.gz $ cd node-v0.3.1 $ ./configure $ make $ sudo make install
The
build options for the V8 engine need to be changed.$ vi node-v0.3.1/deps/v8/SConstruct # For node-v0.3.1, add '-march=armv5t' to 'CCFLAGS', around the 128th line. 126 'gcc': { 127 'all': { 128 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS', '-march=armv5t'], 129 'CXXFLAGS': ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'], 130 },
Use
tar to archive the Node.js executable and shared libraries, and move them to Android.$ tar pcvf node.tar /usr/local/bin/node /lib/librt* /usr/lib/libssl.so.0.9.8 /usr/lib/libcrypto.so.0.9.8 /lib/libdl* /usr/lib/libstdc++* /lib/libm.so.6 /lib/libm-2.7.so /lib/libgcc_s.so.1 /lib/libpthread* /lib/libc.so.6 /lib/libc-2.7.so /lib/ld-linux.so.3 /lib/ld-2.7.so /usr/lib/libz.so.1*
Get
root on the terminal in Android, and execute the following commands:$ su # tar xvf node.tar # /usr/local/bin/node --version v0.3.1
This
is translated version of a Japanese article originally
written by Tom Hughes-Croucher who is working in joynet.
This
article was translated by @jedschmidt.
Special
Thanks to @jedschmidt &
Tom Hughes-Croucher!
相关文章推荐
- Port Node.js to Android running on Genymotion Emulator (x86)
- Node.js on Android
- android WebView onJsAlert onJsConfirm
- node.js+Android http请求响应 分类: Android网络 2014-06-29 12:11 85人阅读 评论(0) 收藏
- android webview onJsAlert只调用一次的问题
- Android 使用node.js 实现与PC端mysql数据库交互
- Latest node.js & npm installation on Ubuntu 12.04
- Step by step instructions to install NodeJS on Windows
- 安装Node.js,系统提示User installations are disabled via policy on the machine
- Node.js+Express on IIS
- INSTALL NODE.JS ON WINDOWS
- npm is known not to run on Node.js vue启动报错
- node.js+Android http请求响应
- 利用node.js android 实现文件上传
- [NodeJS for Android]预编译好的二进制文件
- 安卓系统上的远程 JS 调试 Remote JavaScript Debugging on Android
- node.js中的emitter.on方法使用说明
- Installing node.js on ubuntu server 15.10
- 常用开发工具镜像,不用翻墙,即可下载Chrome Android Studio Gradle Golang NDK SDK NodeJS
- nodejs on centos