DEV Community

Cover image for Android.js - build android apps from nodejs
????
????

Posted on • Originally published at atordvairn.netlify.app

Android.js - build android apps from nodejs

android.js
If You Can Build A Website, You Can Build An Android App!
Android.js simple takes your node.js website and puts it into a WebView.

Yeah, i know that's a lot of disadvantages there but it also provides different APIs for you to interact with.

an android.js application isn't only a WebView like a front end of a site, it can also interact with the backend and interact with files and much more!

installation

install it
To install Android JS binaries, use npm.


 bash
npm install androidjs


Enter fullscreen mode Exit fullscreen mode

Install Android JS project generator and builder


 bash
npm install -g androidjs-builder


Enter fullscreen mode Exit fullscreen mode

initialize


 bash
mkdir AndroidApp
cd AndroidApp
androidjs g
npm install


Enter fullscreen mode Exit fullscreen mode

it will generate a sample project inside AndroidApp directory.

Which will look like:



AndroidApp
    |__ assets
    |       |__ ipc, css, js
    |
    |__ views
    |       |__ index.html
    |
    |__ main.js
    |__ package.json


Enter fullscreen mode Exit fullscreen mode
  • main.js is the main file or we can say it is back process of your app which execute all the code written in node, so you have to write all the node js code inside main.js
  • index.html is the first view which is render by app initially
  • package.json to keep track of all your node packages
  • assets to store all assets of your app

time to build

let's go building


 bash
cd AndroidApp
androidjs b


Enter fullscreen mode Exit fullscreen mode

it will generate apk file inside dist folder

if this build command fails or generated any error, try to build with force command


bash
androidjs b -f
Enter fullscreen mode Exit fullscreen mode




Why not to use it

Android.js isn't better than react-native
But, at least you can (somewhat) throw your existing code in it and generate an API to work on a device just like android application.
React native stays the best way to make Android applications with react (JavaScript).

other resources

docs - documentation for android.js

Sample apps - some sample apps to go with..

conclusion

Android.js is an amazing framework if you don't know react

But if you know react, react native comes in handy at the first place.

originally published here at my blog

Make sure you're subscribed to the high dose javascript newsletter

of course I can't make you, but it take me a considerable amount of time to write these..

tweet this if you like it.
thanks!

Top comments (0)