Cordova: Generate a release APK file instead of an AAB file
Asked Answered
C

6

14

I am trying to generate a release apk file using Cordova 11 with the build.json file. Cordova generates an AAB file instead of an APK file. Here is the command I have used:

cordova build android --release
Certificate answered 15/4, 2022 at 6:5 Comment(5)
What's the problem wit aab?Ashely
No problem with aab. I need release apk.Certificate
Did you check this #53040547 ?Brickey
I am having the same problem. Tried using --packageType=apk with the --release option but didn't work...Oyster
related cordova issues: #1387, #1369, #1377Fredrick
O
31

Finally, I have the answer! Use:

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

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

Oyster answered 21/6, 2022 at 19:55 Comment(2)
I executed this command (cordova build android --release -- --packageType=apk) but still got .aab file 😞Permute
if you, like me, use cordova through quasar you might have to use -- twice, like npx quasar build -m cordova -T android -- -- --packageType=apkFredrick
R
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
Rosenberger answered 10/4, 2023 at 8:56 Comment(2)
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.apkSarette
Probably cordova fixed this. I've changed the answerRosenberger
B
4

If you're on a Windows machine, the following is what worked for me:

Ionic:

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

Non-Ionic:

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

The secret is to escape the --. I got this answer straight from the Cordova Support: Generate .apk instead of .aab file (Ionic Project) #1671

Blanket answered 5/10, 2023 at 13:13 Comment(1)
What worked for me with my non-Ionic app is: cordova build android --release "--" --packageType=apk (note the single "--" instead of the two suggested in this post).Mcdougal
D
1

Confirming that the command that produced .apk is

cordova build android --release -- --packageType=apk 
Dioscuri answered 4/7, 2023 at 21:5 Comment(0)
H
0

I am using ionic with cordova, I am able to generate apk using -- twice

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

Heilbronn answered 28/9, 2023 at 6:42 Comment(0)
T
0

For this issue iam use below command, this was worked for me.

cordova build android --packageType=apk

Thain answered 16/7, 2024 at 14:6 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.