Running Node.Js on Android - android

So I know this has been questioned quite a lot. To be exact for example in these questions:
Run NodeJs server in Android
How to run my node.js project on android?
and
NodeJS on IOS/Android
Every option presented has a problem though:
I want to run it on my normal device so I would like to avoid installing another OS on my Device
Work on JXCore was stopped last month and (maybe as a result) I couldn't get it to compile (see Can't install jxcore-cordova)
The Android Port of NodeJs Anode has not been worked on since 2014 and wasn't really maintained back then anyways
The second answer in the second thread I linked to mentioned there is an official node distribution for Android now but apart from a link to the Browse-Website of the latest dist I couldn't find any info on how to actually use it
I also saw this but it seems like the device has to be connected to a PC (or similar) to run the adb shell commands while I would like to make it as a separate App
With the time that past since these questions have been posted and as the "best option" JXCore seem to be now unusable:
Is there a way to run a node.js application (a server in my case) on an Android device?
if you're wondering why I'd want this: I made a WebApp with a Node.Js server and I now want a version you can launch locally from your phone without requiring an Internet connection. This means the server needs to run on an Android phone.

I just had a jaw-drop moment - Termux allows you to install NodeJS on an Android device!
It seems to work for a basic Websocket Speed Test I had on hand. The http served by it can be accessed both locally and on the network.
There is a medium post that explains the installation process
Basically:
1. Install termux
2. apt install nodejs
3. node it up!
One restriction I've run into - it seems the shared folders don't have the necessary permissions to install modules. It might just be a file permission thing. The private app storage works just fine.

Dory - node.js
Great New Application
No Need to root your Phone and You Can Run your js File From anywere.
node.js runtime(run ES2015/ES6, ES2016 javascript and node.js APIs in android)
API Documents and instant code run from doc
syntax highlighting code editor
npm supports
linux terminal(toybox 0.7.4). node.js REPL and npm command in shell
(add '--no-bin-links' option if you execute npm in /sdcard)
StartOnBoot / LiveReload
native node.js binary and npm are included. no need to be online.
Update instruction to node js 8 (async await)
Download node.js v8.3.0 arm zip file and unzip.
copy 'node' to android's sdcard(/sdcard or /sdcard/path/to/...)
open the shell(check it out in the app's menu)
cd /data/user/0/io.tmpage.dorynode/files/bin (or, just type cd && cd .. && cd files/bin )
rm node
cp /sdcard/node .
(chmod a+x node
(https://play.google.com/store/apps/details?id=io.tempage.dorynode&hl=en)

You can use Node.js for Mobile Apps.
It works on Android devices and simulators, with pre-built binaries for armeabi-v7a, x86, arm64-v8a, x86_64. It also works on iOS, though that's outside the scope of this question.
Like JXcore, it is used to host a Node.js engine in the same process as the app, in a dedicated thread. Unlike JXcore, it is basically pure Node.js, built as a library, with a few portability fixes to run on Android. This means that it's much easier to keep the project up to date with mainline Node.js.
Plugins for Cordova and React Native are also available. The plugins provide a communication layer between the JavaScript side of those frameworks and the Node.js side. They also simplify development by taking care of a few things automatically, like packaging modules and cross-compiling native modules at build time.
Full disclosure: I work for the company that develops Node.js for Mobile Apps.

J2V8 is best solution of your problem. It's run Nodejs application on jvm(java and android).
J2V8 is Java Bindings for V8, But Node.js integration is available in J2V8 (version 4.4.0)
Github : https://github.com/eclipsesource/J2V8
Example : http://eclipsesource.com/blogs/2016/07/20/running-node-js-on-the-jvm/

the tutorial of how to build NodeJS for Android https://github.com/dna2github/dna2oslab/tree/master/android/build
there are several versions v0.12, v4, v6, v7
It is easy to run compiled binary on Android; for example run compiled Nginx: https://github.com/dna2github/dna2mtgol/tree/master/fileShare
You just need to modify code to replace Nginx to NodeJS; it is better if using Android Service to run node js server on the backend.

Node.js Frontend for Android
releases include signed apks
Android 4.4+
open source (GPLv2)
no root
frontend for Node.js for Mobile Apps by Janea Systems
which was announced earlier in this thread by one of its developers
which is a game-changer; great work!
at a high level:
the "exec in same process" tab:
includes a list of Node.js apps that are intended to run for a short period of time while the application remains open, and may only be executed one at a time
the "fork to separate process" tab:
includes a list of Node.js apps that are each executed in a separate foreground service in a distinct process, and are intended to hold long-running daemons (ex: various types of servers)

Related

Can you build React Native apps (Android app) on Ubuntu?

As I can see here you need OS X to build apps with React Native. That is probably because they used it at first to create only iOS apps. Now it's possible to create Android apps with React Native but they still require OS X as development platform which doesn't make sense to me. Is there any way to create Android apps using React Native on Ubuntu OS or any other Linux?
Update 2: I've been developing React native apps on Ubuntu for some time now, without any issues.
Update 1: It's almost possible on linux and windows now. Check this doc page: link
Old answer:
It's already almost working, from the issue shared in kzzzf's answer:
Everything works on Linux except:
react-native run-android can't open a new shell window, you need to
use react-native start. Will be fixed in next release. Debugging in
Chrome currently relies on an AppleScript to launch Chrome. There's a
PR to replace that.
Building on linux and windows is not officially supported although there are people in the community already sending pull requests that will allow to do so (main obstacle is the fact of using apple-script and calling to shell scripts from node - from react-packager and from react-cli).
Main task for tracking those efforts is here: https://github.com/facebook/react-native/issues/2693
While it's not officially supported on Linux yet, and there are certainly some hoops to jump through, I have created a docker container that allows me to build and run android apps from Ubuntu.
The dockerfile is still a work in progress but it's available on github: https://github.com/gilesp/docker/tree/master/react_native
There's a couple of shell scripts to make local development easier - I mainly use the react-bash script to give me a shell prompt in the container for running react-native run-android etc.
It works well enough that I can have a phone connected via USB on my host machine, the react native stuff running in the container and have my edits to the code (I mainly edit using emacs on the host) appear immediately on the device.
I'm currently working on CI builds for android as there are some more hoops to jump through to create the bundled version of the javascript for deployment.
It should be possible by now. For an up to date guide on "can i build for platform X on system Y", see:
https://facebook.github.io/react-native/docs/getting-started.html

Run NodeJs server in Android

Is it possible to run NodeJs server in android device (like linux devices not android apps).
If possible please help me to do it.
And is it possible to start mongo server on Android device?
My devices:
RK3288 TV Box (android 4)
Asus fonepad 7 (android 5 root)
LG Optimus G (android 4 root)
Important!! I want to start a server app in android. because I have an unused android TV-Box and I want to use it in my home server
And I don't want to use it in APK files (to load html files in WebView s). I need nodejs server not javascript client with CommonJs and RequireJs
You might want to install a chrooted-linux on your android-device, as explained here.
In short, do this:
prepare linux-image
do this on any gnu+linux -device.
create a big file (>1 GB)
format it as a filesystem (eg. ext2)
mount it.
copy a distribution inside of it (e.g. with debootstrap)
copy loopdevice to android
mount it (root required)
maybe install busybox
attach some directories from the root-device to the host (usually dev, dev/pts, proc and sys )
chroot
install nodejs inside chroot
note: I have done something similar to my tf301 and it works like a charm. But when I start to use too much memory inside the chroot (e.g. when compiling an android-app), the host will crash. I have not yet experienced those crashes with node and I do not know, if other devices are affected by this.
Install jxcore, as explained here:
Express on Android
The script assumes that Apache Cordova and the Android SDK is installed on your system. If they are not, please refer to individual documentation on how to do this.
Plug an android device into a USB socket (with USB Debugging enabled), unless you want to run the application on the Android Emulator.
Download the script and save it into an empty folder. Run it with a sample folder name as an argument, for example “express sample”:
$ ./install_and_run.sh "express sample"
The Script can be found here.
J2V8 is best solution of your problem. It's run Nodejs application on jvm(java and android).
J2V8 is Java Bindings for V8, But Node.js integration is available in J2V8 (version 4.4.0)
Github : https://github.com/eclipsesource/J2V8
Example : http://eclipsesource.com/blogs/2016/07/20/running-node-js-on-the-jvm/

Developing Ruby on an Android tablet

I want to do Ruby development on an Android tablet, just like on any laptop. So, using vim, git, and rspec to run tests. So, I've found the following apps:
Vimtouch
Ruboto
Git (yes, it's an app)
Terminal Emulator (provides bash)
Each app works just fine. By itself. But, I don't know how to put it all together. I'm a bit of a newbie when it comes to how Android works. So, if anyone could help provide a writeup so that I can:
clone a github repository
edit files from that repository
run my tests
NOTE: I don't want to write an Android app. I want to use my tablet to do Ruby development.
The Android Scripting Environment said to plan on Ruby. Might be worth a check how far they got; at least they're tagged "JRuby" at Google Code. According to their project page:
Scripts can be run interactively in a terminal, in the background, or via Locale. Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell are currently supported, and we're planning to add more.
this can be done
Compile Ruby and Nodejs for android
Install on device and configure with c/c++ ide (You can use
C4droid,CCTools,Terminal IDE.... for installing the expansion
modules on с/с++)

Mobile Chrome Apps: cca checkenv shows no output

I have setup the installation process found on https://github.com/MobileChromeApps/mobile-chrome-apps/blob/master/docs/Installation.md on 2 different linux environments without problem and the same could be said for my current environment until 2 days ago.
Everything on that install for a linux environment is there, was able to run cca prepare android and see my application on my android phone. I dont know what changed but no cca command returns any output.
A whereis cca outputs cca: /usr/local/bin/cca however cca commands returns no response. Any idea or log which i should tail?
Since this doesn't provide any answer, and it seems people are still coming to see this question, I will share my experience related to that problem.
In my case I am trying that on a Ubuntu system (14.04 to be precise).
on my machine I have two packages that one might confuse :
Package: node
Priority: optional
Section: universe/hamradio
Conflicts: nodejs-legacy
Description-en: Amateur Packet Radio Node program (transitional package)
The existing node package has been renamed to ax25-node. This transitional
package exists to ease the upgrade path for existing users.
and
Package: nodejs
Priority: extra
Section: universe/web
Description-en: evented I/O for V8 javascript
Node.js is a platform built on Chrome's JavaScript runtime for easily
building fast, scalable network applications. Node.js uses an
event-driven, non-blocking I/O model that makes it lightweight and
efficient, perfect for data-intensive real-time applications that run
across distributed devices.
.
Node.js is bundled with several useful libraries to handle server
tasks:
.
System, Events, Standard I/O, Modules, Timers, Child Processes, POSIX,
HTTP, Multipart Parsing, TCP, DNS, Assert, Path, URL, Query Strings.
So first make sure you don't mistake one for the other.
Secondly you will need nodejs-legacy to have the node executable ( and not nodejs ).
Once I did this, cca started working.

Python + Django on Android

I am a Django developer and wanted to know if anyone has any idea of the possibilities of installing and developing on Django using an Android tablet such as the nexus 7. This seems like a reasonably powerful device, can be hooked up with a bluetooth keyboard, and has linux at the core of the OS.
So - is it possible to install Python and Django (or even Flask) on Android?
Yeah! its posible!, but you need install termux terminal on Android and later open the termux terminal and write:
apt-update
apt-install python
pip install django
django-admin startproject demo
cd demo
python manage.py runserver 0.0.0.0:8000
and its all, open localhost:8000 on your browser, see the picture:
We're developing PythonAnywhere to fill just this kind of niche. We tuned it to work with the iPad first. But it seems that the Nexus 7 is popular enough now that there might be enough demand to do the same thing for Android.
SL4A is a ridiculously excellent library/sdk/app for android and gives you a way to install a number of language/scripting runtimes and a thin veneer for accessing android functionality via the scripting frameworks.
It so happens that Python is an option, and I've used it with cherrypy (python framework) on Android. I haven't tried it with flask or Django but with some work it should be possible.
The app provides a way to download python, install it, and then a way to launch a python console or even just run python scripts.
http://code.google.com/p/android-scripting/
There was a downside to the python support originally, due to a silly bug/limitation in the Android SDK. This restricted the use of apk assets with _ underscore in the name. The details are faint in my mind, but I am subscribed to the issue in Android so I can follow up with the details about this issue. This would present a problem with many of the python frameworks, as underscores are part of python style.
One good way to accomplish a django development environment on a Nexus7 is to install a linux distro with a package manager alongside Android. Debian Kit hooks into the existing Android directories with symlinks instead of a chroot environment.
With that you can install Debian or Ubuntu and use apt-get and pip to install git, virtualenv, and all the packages and libraries you need to set up your development environment as you would on a desktop. You can write your code in DroidEdit, run the django development server in an Android terminal through ssh to localhost, and test your app right there in the browser on Android.
I could run on my Tablet (android) and smartphone (android) following the procedure below:
Install "GNUroot Debian" app;
Open "GNUroot Debian" app;
Run these commands:
apt-get update
apt-get install python3
apt-get install python3-setuptools
easy_install3 pip
pip install django
django-admin startproject demo
cd demo
python manage.py runserver
QPython suports Django on Android. I am running it on my android device.
Do you want this? :
p.s: I confess that article's original source is me. But isn't it nice? :)
Well if your end goal is to develop Web applications and host host them on your Android and since you had flask there why not give bottle.py a shot. It's just one file that you copy into your sl4a scripts folder and voila. Bottle is minimalist and near similar to flask. No rooting or Unix environments required.
Install termux terminal on Android and later open the termux terminal and write:
pkg install python
pip install django
django-admin startproject demo
vim demo/demo/settings.py
In settings.py
ALLOWED_HOSTS = ['*']
After save the settings.py and
python manage.py runserver 0.0.0.0:8000
and its all, open localhost:8000 on your browser
If you are developing an android app and you don't want to use Java, you might want to consider Kivy http://kivy.org/#home
If you are talking about having a web server running on Android and then running your django web app on that web server itself, there's a duplicate answer here - Web Server for Android

Categories

Resources