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/
Related
I have built an Android version for Intel x86_64 from the Intel Celadon source code. The generated Android image is running on my machine. However, I do not have root access in the Terminal app in the Android device. I don't want the adb shell. I need the root access (sudo) in the Android Terminal app. How can I get that?
In previous Android builds, it was done by changing the init.rc as described in this StackOverflow link. However, this process does not work anymore because of SELinux update in Android. My guess is that there is some capability specification added. Can anybody give any clue on how to build Android from source to give root or sudo access in a Terminal app?
I have an android project checked out from git into an ubuntu server. I will be doing git check-in and check-out files inside this ubunut machine.
I have installed Android studio in my local system .i.e. windows machine.
Is it possible to use FTP in Android Studio to directly import the project from ubuntu server and edit them without copying to my local windows system. I did search around the internet and couldn't find any posts regarding how to do this.
I'm aware that we can install Android studio in Ubuntu itself, but I'm not allowed to do that.
It would be very helpful if anyone throws some light on this.
FTP is not enough, you need something like NFS that allows a user on a client computer to access files over a computer network much like local storage is accessed.
It looks like this functionality is only available on IntelliJ IDEA Ultimate Edition, which Android Studio is based on. It looks like the server only stores the files and IDEA on the client does the heavy lifting. For Android, there's also the question of running emulators, which I assume is also done on the client.
Not sure what the delta is between AS and IDEA, but you can develop Android apps on it.
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)
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
i have the following doubt:
i have read that android os is based on linux, and i imagine it may have the same structure that ubuntu (in terms of file configurations: /root, /dev, etc).
so, is it possible to run an application written in C in android? just as it is possible to do in ubuntu? if so, how can i do that?
also, how can i get access to the root files through an android application (written in java)? and how to get access to the behavior of the os (in terms of interruptions for example)?
thanks in advance for your answers.
gus
Basic answer: Running a C app on Android isn't supported, except through the Native Development Kit (NDK).
You can't get access to the root files except by rooting a phone.
You can get access to some OS behavior through the API. Basically, if it's not part of the API, you can't access it.
The Android OS is based on Linux, but it's an OS, not a windowing server like X or a desktop environment like Gnome or KDE.
You may run C and C++ code on android using NDK. You may use also QT framework. But code is runing in virtual machine named Davlik. Android have root acount , but it is default not available for user. Therefore, access to directory is dependend for chmod.
If you would like read about access to low level in android:
http://www.phrack.org/issues.html?issue=68&id=6
And about architecture this system:
https://developer.android.com/guide/basics/what-is-android.html
You can run programs using Runtime.exec. As an example, you can see Terminal IDE which runs many different programs including ssh, vim and bash. It's also open source so you can learn from the code. You will probably have to include the executable as a resource or asset and then copy to a local directory, grant execute permissions, then run with Runtime.exec. You still have limited user permissions as your app runs under a restricted account unless the device is rooted and you request root access.
an android smartphone/tablet works with an Arm cpu, not a x85. the architecture is different.
but you CAN run a C application in android if you cross compile it for arm linux. or you can use a c compiler inside android device. people ported c compiler to android. you can try C4DROID and in android market. but you can only run compiled program in system memory because of android permissions about sd card.