How to integrate Python scripting in my Android App (like SL4A) - android

I need to add scripting layer to my android App. So I can remotely prepare a script that my app download form a web service and execute on the user device.
I found a interesting project called Scripting Layer for Android (SL4A) here:
http://code.google.com/p/android-scripting/
I'm not sure I can execute Python script without installing the PythonForAndroid_r4.apk first. I can't force my customer to install that application!
So my question is, can the SL4A layer be integrated in my app without the need to install other apk?
I need to execute actions like update data in the DB, create/read/delete a file on the sd card... Not so complex but I see SL4A can do a lot of things like these.
Other scripting libraries?
EDIT:
Found also MVEL: http://mvel.codehaus.org/ but I think it needs to be integrated to execute complex operations like accessing a DB...

I found a project that uses SL4A:
http://code.google.com/p/android-python27/
For whom that wants to try it, if error occurs using Eclipse, here is a link that could solve the compilation issue:
http://code.google.com/p/android-python27/issues/detail?id=1
I've just compiled this project:
http://code.google.com/p/android-python27/source/browse/#hg%2Fapk
To download sources, download HG Tortoise from:
http://tortoisehg.bitbucket.io/download/
Make a local copy of the repository with the command:
hg clone https://code.google.com/p/android-python27/
Then import the APK project in Eclipse and compile it.
Just run it on my low cost China tablet and it seems to works fine. Initially the program make an installation:
boolean installNeeded = isInstallNeeded();
if(installNeeded) {
setContentView(R.layout.install);
new InstallAsyncTask().execute();
}
That make some installations on the external storage (fortunately no root privileges are needed).

Related

Running Node.Js on 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)

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 с/с++)

Running a go program on Android?

I have a go library that i want to run on android and use its methods in my android app. I could write the whole android app in go to make it easier to use this dependency. Is this possible? If so, how?
Download Termux (Linux Emulator) from google play store and open it.
Next, wait for it to perform an automatic download of its resources. After that operation, the run the following command:
pkg install golang
pkg install git
The got package is required when downloading golang packages.
Eventually, you can test it by running (go) command.
Golang support for mobile development has been steadily improving. Today it is even possible to build some simple all Go apps (depending on which features you need) as well as Go libraries. Please see https://github.com/golang/go/wiki/Mobile for more info.
UPDATE: In further improvement, libraries are being created to support even UI on mobile platforms. https://fyne.io provides rather robust set of features for mobile.
You can use a Go library from Java when developing for Android with gobind (see this example in the gomobile repository). The biggest issue with this is integration into the build system.
For Go 1.5 things are getting better, but you'll have to wait for that.

Node.js On Non-Root Android

As the question title states, can I install node.js on Android without root? I have a couple terminal emulator apps and at least one of them has BusyBox, git, and adp, among other things, though I am severely limited in what I can do with them. For example, I can not just git clone the node.js source code, as "No auth methods c[an] be used". I can download the node.js source code, but it seems to be under the "system_server" user as soon as it's downloaded, which I assume is the root user or very close. I am able to unpack it, but unable to run the configure executable in this directory, I assume because it is owned by root as soon as it is downloaded.
Am I trying the right approach here? I have heard about anode, but its wiki is empty and whatever instructions it has are confusing and do not say whether I need to be root. Everything else I have seen tells me I have to have a rooted Android to install node.js, but I hate to give up after so much effort.
Instead installing node.js on the android device, try jxcore.
You can download an android executable binary from its download page, and execute it from the terminal emulator. Remember to set up exec flags.
EDIT: jxcore seems no longer under development.

How to use tweepy module with sl4a and py4a?

I am trying to build a twitter client written in python using tweepy and make it run on sl4a (using py4a) on Android. But i seem to fail to import tweepy module in my main script. The script does not run. Please tell me the correct way to use tweepy in sl4a because copy-pasting the tweepy directory in sl4a's scripts directory does not work.
Download the tweepy .egg for Python 2.6 here : https://pypi.python.org/pypi/tweepy/1.7.1 Make sure it is in the Downloads folder in your SD card. Launch the Python for Android app and select the "import module" option. Select the tweepy .egg file you just downloaded. It should work fine.
The Python for Android app allows you to import module zips, and there are instructions around the web and on the SL4A FAQ about where to copy modules to on the SD card to try and install them as well as installing Python Eggs [link]. You could also try running tweepy's setup.py (found in the download) on the phone.
However, it may also be possible that tweepy has other requirements not present on your phone, such as other modules that would normally be installed by easy_install or the like. While I don't think this is the case it would certainly make installing it very difficult.
At the end of the day, as per the FAQ, I think your best bet is to try copying the tweepy module directory into /sdcard/com.googlecode.pythonforandroid/extras/python.
Good luck!

Categories

Resources