Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Android #359

Closed
rvagg opened this issue Mar 22, 2016 · 16 comments
Closed

Support for Android #359

rvagg opened this issue Mar 22, 2016 · 16 comments
Labels

Comments

@rvagg
Copy link
Member

rvagg commented Mar 22, 2016

@nodejs/build, @nodejs/testing and @nodejs/ctc please weigh in.

https://github.com/nodejs/node/search?q=android&type=Issues&utf8=%E2%9C%93 shows 48 issues and PRs referring to Android support in core. This is something that's not on our radar and mostly exists because there are people out there that keep patching it when it doesn't work properly and we just take their word for it.

Android as a target is interesting because there are an increasing number of devices and applications for Android in the wild. Many (most?) development boards support both Linux and Android, Android is being used in all sorts of new places for control and interface applications. Perhaps it's in our interests to start considering something closer to first-class support for it?

I haven't looked into any of the technicalities of this but it may be straightforward to get Android into our build system as a regular part of our test runs. Newer development boards mean that it shouldn't be too slow either (our ARMv7 and ARMv8 Linux targets run at competitive speeds atm and I'd expect the same performance).

So my questions for you all are:

  • Is this something you've personally had any experience with?
  • Do you have any insight into how Node is being used on Android at the moment?
  • Do you have any thoughts on Node + Android to add to what I've listed above?
  • Is it worth investing some investigative time on this task at least? (I'm not sure who would do this, while I'd love to do it, I'm probably one of the most time-poor people that could do it).
  • Do you have any strong opinions regarding a possible shift toward first-class support of Android (pending investigation and further discussion of course, but initially, what is your reaction to this)?
@shigeki
Copy link

shigeki commented Mar 22, 2016

I built and made test evaluations of Node on my rooted android about a years ago in nodejs/node#1430. The test coverage were bad. To run tests, it needed to disable PIE to run python as nodejs/node#1396 (comment) and it is very hard to have such devices only for Node developments. Unless we have more better environments to develop Node on android, I think that it is hard to continue supporting.

@cablegunmaster
Copy link

  • Is this something you've personally had any experience with?
    Yes, well just a small project for school to use a cart system application on a mobilephone, initial setup:
    Website -> API->Database.
    Mobile phone (Android) -> API ->Database.
    Mobile phone (Android) ->Socket.io ->API->Database.

It was fun to do. Wanted a live synchronisation with JSON to push updated list. so a cart system is updated when someone else added a item to it. (say your family ). also for a practicall use try making a chat application with socket.io (works really nice allong).

  • Do you have any insight into how Node is being used on Android at the moment?
    Socket.io is used as a independent server so you need a Server port and a port open on your mobile phone. Basically its using the socket way of communicating pushing communication along.

http://socket.io/get-started/chat/ -> port open or a environment on the server side where you can control a node server. Look at the example and experiment!

  • Do you have any thoughts on Node + Android to add to what I've listed above?
    Depends on what you are making. socket.io is only used for making the application respond in Realtime.
  • Is it worth investing some investigative time on this task at least? (I'm not sure who would do this, while I'd love to do it, I'm probably one of the most time-poor people that could do it).
    Basically it makes your application you are trying to develop more realtime, its only worth building in if it needs to alter in realtime data, lets say weather information, locations of other vehicles on maps (JSON data pushed , and updated). At least this is my analyses from the mobile point of view.
  • Do you have any strong opinions regarding a possible shift toward first-class support of Android (pending investigation and further discussion of course, but initially, what is your reaction to this)?
    I like socket.io and love to make a game based upon the socket.io framework. but same as you starved for time. Its fun, but you have to wonder if this is the way your application should go upon. Does it need realtime updating? Or is it just because you love the feature?

@mhdawson
Copy link
Member

In terms of building apps that use javascript for android there is https://cordova.apache.org/ and you can use things like socket.io in those applications. So my initial thinking is that use cases where Node would be used to support a server running on android as opposed to client applications would make a stronger case.

@bsegault
Copy link

I'll try to answer your questions:

Is this something you've personally had any experience with?

I'm currently working on a multi-platform project that partly relies on Node. Since we want to use smartphones, android is unavoidable; so we built our application for Android (ARM & x86), and recompiled Node.js for Android. So I'm no expert, but I'm working on it =)

Do you have any insight into how Node is being used on Android at the moment?

Not really. I'm hearing about stuff like Cordova & jxCore, but I don't think that many developers are using Node as-is in Android (because of the structure of an Android package, it's not intuitive to use node in "standard" Android packages, IMHO).

Do you have any thoughts on Node + Android to add to what I've listed above?

Not really.

Is it worth investing some investigative time on this task at least?

I think it's worth investigating how developers can benefit of Node.js on mobile platforms, and what can the community & Node developers do about it. It's no random act that people talk more & more about Cordova & jxCore, though I have no idea of how those work.

@lamuertepeluda
Copy link

👍 for Android support. I can answer to the questions as well:

  1. yes, since the time I was involved in webinos project. At that time we were relying on anode, a partial port of node.js which I think now is stopped. That said, both node.js and the hardware capable of running it have made giant leaps forward, so it should be even easier to achieve node running inside an android app. A great tool for running node on Android right now is Termux. Another interesting project is nodekit which claims Android support too, but does not seem to implement it yet, perhaps because of its early stage of development.
  2. I don't have really insight of how node is being used on Android right now, but I've tried jxcore (and it's companion jxcore-cordova-plugin) and they seemed to be fit for the scenario I had in mind. Sadly Nubisa has stopped developing jxcore, which was also stuck to 0.10.x API. Other projects seem to have similar targets, including the aforementioned nodekit.io. I expect the use-case would be like on Windows10-based or Linux-based arm boards, where ad-hoc builds of node.js are used to behave like small server or whatever... anyway on a platform like android (let's not just focus on mobile phones, but also on TV, raspberries, tablets and other devices capable of running it) I expect even more possibilities of interaction.
  3. Sockets.io/websockets is just one of the possibilities, even though one of the most interesting: it could be possible, for instance, of embedding small in-app web servers (static or dynamic), with superior performances and features compared to others (e.g. NanoHTTPD, quite simple but also really slow).
    @mhdawson with cordova you can just add a socket.io client to your app, but not a server, afaik
  4. Yes, I think it would be worth. Perhaps starting from what has been already made by other projects.
  5. It would be great to have the possibility of embedding it as a library - basically having a sort of wrapper for Android apps. I think the jxcore model is the right direction. An official cordova plugin would be the icing on the cake, but that's perhaps asking too much. 😄

@dianahinz
Copy link

💯

@lamuertepeluda Agree on Jxcore direction. Jxcore did a very good integration with Android. node fs was able to read from APK.

ping @obastemur ! I guess you have the most experience here.

@gardner
Copy link

gardner commented Apr 13, 2016

It was fun while it lasted but jxcore is no longer maintained. It would be rad if there were jxcore style android-ndk build facilities in nodejs mainline. The cordova plugin makes it easy to create a hybrid app that can connect to the in-process node/jxcore instance.

For an example of a client-server application that runs locally you can checkout the decentralized app patchwork. I have been trying to compile that project for android with little success.

🙇

@mihailik
Copy link

mihailik commented May 18, 2016

I've been using node on Android on Debian chroot as part of using a tablet for development instead of a laptop.

That is, using node-based tools for compiling, inlining, uglifying and self-hosting from a terminal.

Chroot is a royal pain to maintain, otherwise the usage and patterns repeat the pure naked Android nodejs patterns: terminal, localhost:XXXX, browser etc.

The short-term practical production usage limitations are:

  • no idea how to build/download node for Android (that's why I've gone chroot/Debian)
  • is rooting needed? (ideally no)
  • occasionally OS kills non-interactive processes to free resources
  • how to spot and terminate runaway node processes?
  • ability to prevent sleeping would be nice

On the other hand, easy way of hosting servers on a commodity Android device will be a heaven's blessing for poor countries. Cheap smartphones become a prevalence even in poorest areas, and being able to run school's website from a $40 phone makes a big difference.

@gardner
Copy link

gardner commented May 19, 2016

I was able to build the node binary for android using the android-configure script in the main repo. You need to download the Android NDK and build from Linux. I used an Ubuntu 15 vm. It builds the node binary which can then be pushed to /data/local/tmp on the device.

My work is available in this repo: https://github.com/gardner/ssband

@eljefedelrodeodeljefe
Copy link

I am trying to make some efforts about this. nodejs/node#3098 landed just now and if you guys have other stuff that would be useful upstream, please feel free to give it a shout. I am collecting some info from your links in any case. Thanks!

@Trott
Copy link
Member

Trott commented Nov 7, 2017

Should this remain open? If so, is there a label that might be useful to add such as help wanted?

@rvagg rvagg closed this as completed Nov 8, 2017
@rvagg
Copy link
Member Author

rvagg commented Nov 9, 2017

FYI I only closed this because there's been no movement. If someone wants to pick this up and figure out a path to better Android support then by all means reopen it or open a new issue.

@gardner
Copy link

gardner commented Nov 10, 2017

I'm not part of the core group here. In my experience the first ticket to bring up an issue is left open so duplicates can be closed. Since this is the first issue that was logged to track android support, new github issues are closed by referencing #359 as the issue that it duplicates. I understand keeping things tidy but it may be hard to close a new issue as a dup if the original issue that it is duplicating has been closed.

That said, nodejs does build for Android. The build repo does not enable that in any way. I'm not sure if it's worth the effort to move it into this repo unless someone wants it.

If someone wants to pick this up and figure out a path to better Android support then by all means reopen it or open a new issue.

I guess that's kind of the point @Trott was making. If we leave it open then new folks can see it as a potential way to help.

This was a pretty long comment for my very agnostic view on the matter.

@rvagg rvagg reopened this Nov 10, 2017
@rvagg
Copy link
Member Author

rvagg commented Nov 10, 2017

Case made

@d3x0r
Copy link

d3x0r commented Jun 29, 2018

I picked up this today; I would like to use node as a .so I can load into some android app.
I can't get it to build at all.

In file included from ../deps/icu-small/source/common/unicode/unistr.h:31:0,
                 from ../deps/icu-small/source/common/unicode/brkiter.h:47,
                 from ../deps/icu-small/source/common/locdispnames.cpp:23:
/home/d3x0r/work/node/android-toolchain/include/c++/4.9.x/cstddef:44:28: fatal error: bits/c++config.h: No such file or directory
 #include <bits/c++config.h>

I would think stddef should be able to find bits/c++config.h
but I don't know where that would be defined; it's apparently internal? something --sysroot?

find . -name c++config.h
./android-toolchain/include/c++/4.9.x/arm-linux-androideabi/armv7-a/thumb/bits/c++config.h
./android-toolchain/include/c++/4.9.x/arm-linux-androideabi/armv7-a/bits/c++config.h

nodejs/node#9707 referenced the same missing .h and there was a modification to add --force installing the standalone toolchain? (that didn't help) I might have missed some other thing that would fix this.

@github-actions
Copy link

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests