Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate .apk instead of .aab file (Ionic Project) #1671

Closed
Morgs007 opened this issue Oct 4, 2023 · 6 comments
Closed

Generate .apk instead of .aab file (Ionic Project) #1671

Morgs007 opened this issue Oct 4, 2023 · 6 comments
Labels
info-needed / awaiting response Further information is requested

Comments

@Morgs007
Copy link

Morgs007 commented Oct 4, 2023

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

@breautek
Copy link
Contributor

breautek commented Oct 4, 2023

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.

@breautek breautek added the info-needed / awaiting response Further information is requested label Oct 4, 2023
@Morgs007
Copy link
Author

Morgs007 commented Oct 5, 2023

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.

See below screenshot of what I am talking about:
image

@breautek
Copy link
Contributor

breautek commented Oct 5, 2023

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.

@Morgs007
Copy link
Author

Morgs007 commented Oct 5, 2023

@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

@breautek
Copy link
Contributor

breautek commented Oct 5, 2023

I've created a ticket on the docs repo (apache/cordova-docs#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.

@breautek breautek closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2023
@Morgs007
Copy link
Author

Morgs007 commented Oct 5, 2023

Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed / awaiting response Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants