Is it possible to deploy an app you built with electron to android?
Asked Answered
G

2

16

I know that you can use electron for cross platform applications (windows, macos, linux) but is there a way to get it to run on android?

Gdynia answered 9/3, 2022 at 19:35 Comment(0)
C
8

I know it's a few months late but yes, you can. Apache Cordova uses Electron as one of its platforms and this seems to work like a charm.

Cordova normally creates apps for Android and iOS using JS but with the Electron platform, it can create all the Electron outputs as well like Windows/Mac/Linux by including node.js.

Cassareep answered 3/8, 2022 at 1:22 Comment(8)
Some links to examples or documentastion would be great here. I can't find anything that points to, that this is possible. Cordova, now replaced by Capacitor by the Ionic folks seems to support bringing IOS/Android apps to the desktop using Electron, but not the other way around. At least according to what I can find. If anyone reading this know different please share info, thanks.Convene
cordova.apache.org/docs/en/latest/guide/platforms/electron/…Cassareep
how is it going? Is @Peter right about it?Romy
By the way, this answer by @Cassareep is wrong.Romy
As of mid 2024 , this is 100% wrong. Not sure why this has many upvotes. YOU CANNOT INSTALL ELECTRON APP ON MOBILE DEVICES!!! ELECTRON IS SPECIFICALLY FOR DESKTOP!!!!Epizootic
@Epizootic Travis mentioned Apache Cordova uses Electron for Desktop modes, but for Android/iOS it uses it's own system. So indeed, Electron doesn't work for mobile, but Cordova is used to work for the mobile devices.Adaptive
@Adaptive -- no sh!t..... I was specially talking about electron for android.Epizootic
@Epizootic yes, and we know that. We all specifically write Electron is used for desktop and Cordova used for mobile, I don't know why you said he was wrong and is yelling? Nowhere does he say electron is used for android. I think you may have misunderstood the OP? He was saying that Cordova used to be mobile only, but now with electron it can output all platforms (electron being responsible for the desktop)Adaptive
R
3

Electron means "Webview"(based on Chromium) is connected to javascript outside (I emphasize outside since inside a Webview, we can always use javascript). And the javascript is in particular nodejs. By the way, Chromium "webview" connected to python is "CEF Python", which is exactly parallel to electron.

On android, for the usual webview(also based on Chromium), its outside is connected to Java VM. If we want to use this webview, and its outside connected to javascript, this connection is through Java VM. Either a JS engine runs in Java VM or this one https://github.com/nodejs-mobile/nodejs-mobile-cordova.

The other option is to build the webview from Chromium by ourself. With this approach, java VM is not involved. This is:

  1. for android: https://chromium.googlesource.com/chromium/src/+/main/docs/android_build_instructions.md (seems should "Build Content shell" rather than "Build WebView" which also connect to Java VM)
  2. for iOS: https://chromium.googlesource.com/chromium/src/+/main/docs/ios/build_instructions.md

And its outside can be connected to Javascript directly, to execute JS, we need a JS engine for the outside javascript. JS engine is not only to execute JS code, but also to provide environmental support. This is https://github.com/nodejs-mobile/nodejs-mobile

Romy answered 29/11, 2023 at 5:35 Comment(4)
You're splitting hairs here. OP is asking if he can dev for Windows/Mac/Linux desktop and use that same code in an android app. Cordova absolutely 100% can do this and is its primary mission. I have a couple major products in the wild doing exactly that. Cordova runs JS in a packaged version of Chromium on all these platforms.Cassareep
In the original question, the key word is electron. You said you "have a couple major products in the wild doing exactly that", I am wondering whether they use electron? or just a website with web browser? If electron(nodejs) is used is used, then what I said is relevant. If electron is not used, then what you said is indeed right.Romy
Take a look here: cordova.apache.org/docs/en/latest/guide/platforms/electron/…Cassareep
thank you for discussion. You had post the link on September 9, and as @peter stated, if you have a website, by using Cordova, you can build apps for android, iOS, electron. But in reverse, if you have an app built with electron and if nodejs is used, then the link you post won't be able to help you to turn your electron app into an app for android or for iOS. Though when nodejs is not used, then your electron app can be build for browser, electron, android, iOS. But in this case, electron and browser are just same! Technically, there is no point to use electron.Romy

© 2022 - 2024 — McMap. All rights reserved.