13

I am trying to generate release apk file using cordova 11 with build.json file. Cordova generates aab file instead apk. Here is the command I have used

cordova build android --release

Sathesh Kumar
  • 359
  • 3
  • 8

3 Answers3

22

Finally, I have the answer! Use:

cordova build android --release -- --packageType=apk

Got this answer from a youtube user called Harag. Thank you Harag.

Miguelp25
  • 411
  • 3
  • 12
  • 3
    I executed this command (`cordova build android --release -- --packageType=apk`) but still got .aab file – Pavel Chuchuva Oct 04 '22 at 23:59
  • 2
    if you, like me, use cordova [through quasar](https://v1.quasar.dev/quasar-cli/developing-cordova-apps/build-commands) you might have to use `--` twice, like `npx quasar build -m cordova -T android -- -- --packageType=apk` – kubi Nov 02 '22 at 09:16
4

Build with cordova command:

cordova build android --packageType=apk

It will create .apk in debug mode and depending on cordova version in release. You can also create .aab and use bundletool (see android bundletool) to extract apks like this:

bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
Andrey Efimov
  • 371
  • 3
  • 7
  • Not sure about the first part... I ran it with the `--release` flag and it gave me: `platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk` – M.K Jul 03 '23 at 11:18
  • 1
    Probably cordova fixed this. I've changed the answer – Andrey Efimov Aug 02 '23 at 17:10
0

Confirming that the command that produced .apk is

cordova build android --release -- --packageType=apk 
Taras Gleb
  • 158
  • 2
  • 5