Making apps with electron for android


#1

Is it possible to use electron to create .apk files like one would create an executable file for windows, os x or linux?

If not, what are some alternatives?


#2

Maybe React Native is what you need …( ゚Д゚)ノ⌒React Native


#3

It should be possible with a combination of the child_process functions (e.g exec, execFile, spawn) and the Android SDK. Just use the child_process functions to execute the command for creating the .apk file.

apk build command: “ant -Dsdk.dir= debug” (old command based on eclipse) .

Check the Android SDK documentation for the latest information on building the apk from the command line: http://developer.android.com/tools/building/building-cmdline.html

Example:

Render process (index.html)

<script type="text/javascript">
    var ipc = require('ipc');
    ipc.send('create_apk', 1);

	ipc.on('create_apk_response', function(arg) {
 		document.getElementById('div').innerHTML = "apk file name: " + arg;
	});
    </script>

main process (main.js)

var ipc = require('ipc');
ipc.on('create_apk', function(event, arg) {
  var e = require('child_process');
  e.exec('ant -Dsdk.dir='+ ANDROID_SDK_PATH +' debug', function(err,stdout, stderr) {
  // process stdout, stderr printouts and get the apk filename if successfull
  // return the apk file name in stdout
  event.sender.send('create_apk_response', stdout);
  });
});

#4

It only works on os x :confused:


#5

This must be a thing. I electron updated to alow android app development it would open a whole new world for developers and would make electron the go to development platform for practically anything.


#6

With termux https://termux.com/ we can install nodejs on android https://www.youtube.com/watch?v=lnlH_yvYwE0
Could it be possible to wrap in a unique app, termux, nodejs a server and a webview which comunicates with the server to call the functions of nodejs? In this way we would use the node library instead of cordova plugin and then major portable code.


#7

Unfortunately according to https://github.com/electron/electron/issues/562 porting electron would be nearly impossible. The underlying APIs are very different. Remember electron is a native C++/Python app, it uses nodejs but that’s not the foundation.