Comments (3)
@gikarasojo there are several ways to be able to run javascript app.
Method 1:
ref: https://github.com/dna2github/dna2mtgol/blob/master/fileShare
- Step 1. compile node js with the build script provided in this repo (or download from release page).
- Step 2. put compiled node js binary file to resource folder of your Android project.
- Step 3. in MainActivity.java of (ref),
InputStream nginx = app.getResources().openRawResource(R.raw.nginx);
; you can write code similarly to open a file in application data folder, read the stream and write to the file; grant executing permission to the file - Step 4. similar to NginxServer.java of (ref),
p = Runtime.getRuntime().exec(cmd);
you can write some code to start a thread and set cmd for example/data/data/com.myapp.nodejs/binary_nodejs /sdcard/hello/index.js
(i.e.class Server extends Thread { @override public void run() { String cmd = "/data/data/com.myapp.nodejs/binary_nodejs /sdcard/hello/index.js"; Process p = Runtime.getRuntime().exec(cmd); p.waitFor(); /* new Server().start() to kick off the background server and kill p when want to stop*/ } }
, the difference between Nginx and NodeJS is that Nginx runs in daemon mode and NodeJS runs in foreground, if you directly run in the code without a thread,waitFor
method will block your app until the NodeJS process is terminated.). Thenp
is a process of node js app. (if you run a js server, remember to declare permission statement in AndroidManifest.xml)
Method 2:
ref: https://github.com/shadowsocks/shadowsocks-android
- Step 1. read the configuration of src/main/jni/Android.mk in (ref); copy the build script provided in this repo into the file with Makefile style; config resource folder as build target
- Step 2-3. the same to Step 3-4 of Method 1
Method 3:
If you know some Linux system programming, you can also use mmap, load node js binary into memory and then run node js app, to save storage space.
Method ...
Thanks,
Seven
from dna2oslab.
update: https://github.com/dna2github/dna2mtgol/tree/master/nodeBase/platform
a simple android app to run NodeJS
from dna2oslab.
there is README file to have a guide. close it.
from dna2oslab.
Related Issues (19)
- [Android] rewrite python shell to patch Makefile instead
- nginx without http-rewrite HOT 2
- how to dec file with name bin-node-v8.4.0, i dont know file type (mac os)... HOT 1
- build node v8.4.0 error HOT 1
- 编译haproxy提示缺少文件。 HOT 2
- 可以提供.a文件的导入库和头文件吗? HOT 1
- it's not a problem it's just that I don't understand HOT 1
- 每次运行nginx都会在bin-nginx-1.10.2所在目录下产生一个error.logs HOT 5
- 系统错误日志路径配置 HOT 1
- 运行nginx-1.18.0.sh时报错 HOT 2
- [Android] build nginx on android HOT 1
- node编译出错 HOT 4
- 方便提供个nginx的arm64-v8a的静态库吗? HOT 3
- [Android] build mariadb on android HOT 1
- rewrite a common script to cover nginx cross-compiling
- [bug] nodejs compilation failed
- [build_base] replace gcc to clang HOT 4
- Node 7.1.0 script runs well up-to 7.10.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dna2oslab.