Closed Morgs007 closed 6 months ago
The Cordova CLI uses cordova build android --release -- --packageType=apk
.
I can't speak for third-party CLI's like ionic and all information below is assuming pure cordova environment.
On windows, if you're using Command Prompt or Powershell, I think the intermediate --
needs to be in quotations: cordova build android --release "--" --packageType=apk
, for the shell to properly pass-through the arguments
Also note that I believe the build output will print out all apks/bundles thats in your build output directory. So it will include text stating that it "built" a file even if that file wasn't actually built from your last command, but purely because the file already existed in the build/outputs directories.
In otherwords, you should see the APK in platforms/android/app/build/outputs/apk/release/
and you should see that printout, but you may also (incorrectly) see printouts about it building aab
files as well. This might be a source of confusion.
The command hasn't changed since it was first introduced in v10 and building both AABs and APKs is part of my workflow so I'm pretty confident it works (On Linux/Mac machines anyway). Let me know if this helps.
The Cordova CLI uses
cordova build android --release -- --packageType=apk
.I can't speak for third-party CLI's like ionic and all information below is assuming pure cordova environment.
On windows, if you're using Command Prompt or Powershell, I think the intermediate
--
needs to be in quotations:cordova build android --release "--" --packageType=apk
, for the shell to properly pass-through the argumentsAlso note that I believe the build output will print out all apks/bundles thats in your build output directory. So it will include text stating that it "built" a file even if that file wasn't actually built from your last command, but purely because the file already existed in the build/outputs directories.
In otherwords, you should see the APK in
platforms/android/app/build/outputs/apk/release/
and you should see that printout, but you may also (incorrectly) see printouts about it buildingaab
files as well. This might be a source of confusion.The command hasn't changed since it was first introduced in v10 and building both AABs and APKs is part of my workflow so I'm pretty confident it works (On Linux/Mac machines anyway). Let me know if this helps.
See below screenshot of what I am talking about:
Can you try cordova build android --release "--" --packageType=apk
?
I don't use windows so I kinda forget but I'm pretty sure windows requires that separating --
to be enclosed quotations like above.
@breautek that worked, thanks a lot. I see a lot of people are complaining about the same issue on stackoverflow so I will go and answer using your recommendation
I've created a ticket on the docs repo (https://github.com/apache/cordova-docs/issues/1336) as well, so that we can improve our docs on this caveat.
I'm closing this issue because it's not really a bug.
Thanks for your help
Bug Report
I am trying to generate a .apk file but whatever command I try I keep getting a .aab file. What is the new command to use in order for one to successfully generate a .apk file?
Problem
I used the following commands to no success:
ionic cordova build android --release --packageType=apk
ionic cordova build android --prod --release -- --packageType=apk
cordova build android --release -- --packageType=apk
cordova build android --prod --release -- -- --packageType=apk
What is expected to happen?
Produce a .apk file
What does actually happen?
All the commands produces a .aab file
Command or Code
ionic cordova build android --release --packageType=apk
ionic cordova build android --prod --release -- --packageType=apk
cordova build android --release -- --packageType=apk
cordova build android --prod --release -- -- --packageType=apk
Version information
Cordova Platforms : android 12.0.1 Cordova CLI : 12.0.0 (cordova-lib@12.0.1) Ionic CLI : 6.20.8 @angular-devkit/build-angular : 15.2.7 @angular-devkit/schematics : 15.2.7 @angular/cli : 15.2.7 @ionic/angular-toolkit : 9.0.0 native-run : 1.7.2 Android SDK Tools : 26.1.1 NodeJS : v18.16.1 npm : 9.6.0 OS : Windows 10