Git Product home page Git Product logo

node-android's Introduction

node-android

Android CI

Run Node.js on Android by rewrite Node.js in Java with the compatible API.

third-party: libuvpp, libuv-java JNI code by Oracle.

Build

Clone the code, open Android Studio (1.*) and import the project.

For Eclipse ADT user, refer to ADT branch

Javascript code injection

> adb shell am start -a android.intent.action.VIEW -n com.iwebpp.nodeandroid/.MainActivity -e js "var run = function () { return 'hello world'; } run();"

Features

JS runtime

  • Rhino supported
  • Exposed node-android packages: com.iwebpp.node.http, com.iwebpp.node.stream, com.iwebpp.node.net, etc
  • Exposed node-android classes: com.iwebpp.node.EventEmitter2, com.iwebpp.node.Dns, com.iwebpp.node.Url, etc
  • Exposed node-android native context in JS standard scope as NodeCurrentContext alias NCC
  • Exposed Android API: android.util.Log
  • NodeJS compatible internal modules are available in JS standard scope
  • Exposed WebSocket classes: com.iwebpp.wspp.WebSocket, com.iwebpp.wspp.WebSocketServer

JS usage

  • In case Rhino, create class 'MyScript' extends from com.iwebpp.node.js.rhino.Host
  • Implement 'public String content()' in 'MyScript' to return user script
  • Execute JS engine in a separate Java Thread with 'MyScript.execute()'
  • When authoring script, please use NodeCurrentContext(alias NCC) in node-android API
  • JS API usages details

TODO

  • API doc, more demos
  • JS runtime CommonJS/AMD compliance

Support us

  • Welcome contributing on document, codes, tests and issues

### License

(see LICENSE file)

Copyright (c) 2014-present Tom Zhou([email protected])

node-android's People

Contributors

buggaboo avatar sequoiar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-android's Issues

Add `android` module to access its API

node-android could have its platform specific module, allowing to access Android API like:

var android = require('android'),
    Canvas = android.graphics.Canvas,
    Service = android.app.Service,
    ViewGroup = android.view.ViewGroup;
    myView = new ViewGroup(context);
setContentView(myView);
myView.requestFocus();

run JS engine on node-android

some people asked about run overall node.js npm, etc.

But, Android framework does provide most of device capability. I am still wonder if make sense to run JS engine on JVM.

crypto/tls

implement end to end security over tcp/udt/ws.

What is httpp?

Could you explain what httpp is in the code? I tried googling of course.

'ARMV7A_FILTER' is missing an input or output annotation

Hello ๐Ÿ‘‹๐Ÿป
am try to compile this project using Android Studio Chipmunk | 2021.2.1
and am getting this error below, how can I solve this ? thanks.

Some problems were found with the configuration of task ':app:resolveNativeDependencies' (type 'NativeDependenciesResolverTask').

  • In plugin 'android-native-dependencies' type 'com.nabilhachicha.nativedependencies.task.NativeDependenciesResolverTask' property 'ARMV7A_FILTER' is missing an input or output annotation.

cant build/run

i get the following error using android studio on mac

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild
:app:compileDebugNdk
/Users/bornfree/AndroidstudioProjects/node-android-httpp/app/src/main/jni/async.cpp:31:16: fatal error: uv.h: No such file or directory
compilation terminated.
make: *** [/Users/bornfree/AndroidstudioProjects/node-android-httpp/app/build/intermediates/ndk/debug/obj/local/armeabi-v7a/objs/uvpp-prebuilt//Users/bornfree/AndroidstudioProjects/node-android-httpp/app/src/main/jni/async.o] Error 1

FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugNdk'.

    com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/bornfree/ndk-r10b/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/bornfree/AndroidstudioProjects/node-android-httpp/app/build/intermediates/ndk/debug/Android.mk APP_PLATFORM=android-19 NDK_OUT=/Users/bornfree/AndroidstudioProjects/node-android-httpp/app/build/intermediates/ndk/debug/obj NDK_LIBS_OUT=/Users/bornfree/AndroidstudioProjects/node-android-httpp/app/build/intermediates/ndk/debug/lib APP_ABI=all
    Error Code:
    2
    Output:
    /Users/bornfree/AndroidstudioProjects/node-android-httpp/app/src/main/jni/async.cpp:31:16: fatal error: uv.h: No such file or directory
    compilation terminated.
    make: *** [/Users/bornfree/AndroidstudioProjects/node-android-httpp/app/build/intermediates/ndk/debug/obj/local/armeabi-v7a/objs/uvpp-prebuilt//Users/bornfree/AndroidstudioProjects/node-android-httpp/app/src/main/jni/async.o] Error 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1.803 secs

Can't find method com.iwebpp.node.http.http.createServer

hi,
i'm trying to run simply code from the editor:

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

but i have error: Can't find method com.iwebpp.node.http.http.createServer
Which is strange because i see the method in the code. I do not know what to do.
The whole log:

D/MainActivity( 1240): start test
D/dalvikvm( 1240): Trying to load lib /data/app-lib/com.iwebpp.nodeandroid-1/libuvpp-jni.so 0xb1d79098
D/dalvikvm( 1240): Added shared lib /data/app-lib/com.iwebpp.nodeandroid-1/libuvpp-jni.so 0xb1d79098
D/dalvikvm( 1240): No JNI_OnLoad found in /data/app-lib/com.iwebpp.nodeandroid-1/libuvpp-jni.so 0xb1d79098, skipping init
D/dalvikvm( 1240): GC_CONCURRENT freed 259K, 9% free 3292K/3612K, paused 4ms+4ms, total 51ms
D/dalvikvm( 1240): GC_CONCURRENT freed 226K, 8% free 3501K/3792K, paused 4ms+4ms, total 44ms
D/dalvikvm( 1240): GC_CONCURRENT freed 242K, 8% free 3719K/4028K, paused 19ms+15ms, total 77ms
D/dalvikvm( 1240): GC_CONCURRENT freed 253K, 7% free 3927K/4208K, paused 4ms+4ms, total 59ms
E/RhinoHost( 1240): org.mozilla.javascript.EvaluatorException: Can't find method com.iwebpp.node.http.http.createServer(function). (UserContent#8)
W/System.err( 1240): java.lang.Exception: Rhino runtime exception: org.mozilla.javascript.EvaluatorException: Can't find method com.iwebpp.node.http.http.createServer(function). (UserContent#8)
W/System.err( 1240): at com.iwebpp.node.js.rhino.Host.execute(Host.java:312)
W/System.err( 1240): at com.iwebpp.nodeandroid.MainActivity$2.run(MainActivity.java:202)
W/System.err( 1240): at java.lang.Thread.run(Thread.java:841)
D/MainActivity( 1240): exit test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.