在android上运行io.js

栏目: 编程语言 · 发布时间: 8年前

内容简介:在android上运行io.js

无意中看到io.js在4月份开始已经支持android编译,果断弄一个

环境

opensuse 11.4 x86

android 4.2.2 linux 3.2, 已root

下载并安装NDK r10e

http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86.bin

直接下载挺慢的,走百度云就很快

在opensuse切换到root,然后运行

cd /opt
./android-ndk-r10e-linux-x86.bin

即可自行解压出ndk

下载并编译io.js

cd /opt
# 或者百度云下载也可以,更快
wget https://iojs.org/dist/v2.1.0/iojs-v2.1.0.tar.gz
tar xf iojs-v2.1.0.tar.gz
cd iojs-v2.1.0
./android-configure /opt/android-ndk-r10e
make -j8

无异常,无Error,顺利编译完成

传输到android上

adb remount
adb shell mkdir /system/iojs
adb push out/Release/iojs /system/iojs/iojs
adb push lib /system/iojs/iojs
adb shell chmod 777 /system/iojs/iojs

尝试运行一下

先弄个官网demo, 存为example.js

var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');

传到android上

adb shell mkdir /sdcard/iojs/
adb push example.js /sdcard/iojs/
adb shell /system/iojs/iojs /sdcard/iojs/example.js

访问一下android设备上的服务,哈哈

curl -v http://192.168.72.107:8124/

输出如下内容,搞定

*   Trying 192.168.72.107...
* Connected to 192.168.72.107 (192.168.72.107) port 8124 (#0)
> GET / HTTP/1.1
> Host: 192.168.72.107:8124
> User-Agent: curl/7.42.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/plain
< Date: Thu, 28 May 2015 02:13:18 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
< 
Hello World
* Connection #0 to host 192.168.72.107 left intact

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

HTML5

HTML5

Matthew David / Focal Press / 2010-07-29 / USD 39.95

Implement the powerful new multimedia and interactive capabilities offered by HTML5, including style control tools, illustration tools, video, audio, and rich media solutions. Understand how HTML5 is ......一起来看看 《HTML5》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具