How to compile an Electron app to a mobile app?

139 Views Asked by At

I have been trying to compile my Electron app into either an APK or an IPA, but I have had trouble doing this. If I can't do it, I was wondering if I can convert a .exe file to a .apk or something similar.

I've tried using electron-builder as it says it can export to .apk, but it won't work saying that the file is corrupted (tried exporting to arm64, x64, and armv7l). I was seeing that Apache Cordova supports Electron, but I can't find a way to migrate an existing Electron app to it.

Someone told me I can add a packager.json file but it won't work even with that. This is my packager.json:

{
  "electron_version": 5,
  "name": "random app name",
  "version": "1",
  "description": "random app description",
  "background": {
    "scripts": ["index.js"],
    "persistent": true
  },
  "permissions": [
    "camera",
    "microphone",
    "<clipboard>"
  ]
}

This is my current package.json I have currently:

{
  "name": "random app name",
  "version": "1.0.0",
  "description": "random app description",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "./node_modules/.bin/electron-builder",
    "postinstall": "./node_modules/.bin/electron-builder install-app-deps",
    "start": "electron ."
  },
  "build": {
    "appId": "com.random.app",
    "productName": "Random App",
    "copyright": "© 2024 Random App",
    "mac": {
      "icon": "renderers/img/logo.png"
    },
    "win": {
      "icon": "renderers/img/logo.png"
    },
    "linux": {
      "icon": "renderers/img/logo.png",
      "category": "AudioVideo"
    }
  },
  "keywords": [
    "social",
    "video",
    "community"
  ],
  "devDependencies": {
    "electron": "^28.2.1",
    "electron-builder": "^24.12.0"
  },
  "dependencies": {
    "@sentry/electron": "^4.17.0",
    "axios": "^1.6.7",
    "jwt-decode": "^4.0.0",
    "keytar": "^7.9.0",
    "os": "^0.1.2",
    "url": "^0.11.3"
  },
}

(i shortened the package.json a little bit to fit)

If anyone can help, please let me know. Thank you!

0

There are 0 best solutions below