Building with --release does not create a release apk

All documentation online seems to indicate that when I need to make a release build, all I have to do is run ionic build --prod --release and I should end up with an apk in android/app/build/outputs/apk/release/ directory.

But, I don’t get that. I just have the debug apk in the debug directory. I don’t see any errors in the Android Studio output – it says “Build succeeded.”

Am I misunderstanding something? Do I have to configure something else?

My setup:

$ ionic info

Ionic:

   Ionic CLI                     : 6.16.3 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.5.1
   @angular-devkit/build-angular : 0.1000.8
   @angular-devkit/schematics    : 10.0.8
   @angular/cli                  : 10.0.8
   @ionic/angular-toolkit        : 2.3.3

Capacitor:

   Capacitor CLI      : 3.0.0
   @capacitor/android : 3.0.0
   @capacitor/core    : 3.0.0
   @capacitor/ios     : 3.0.0

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : none
   Cordova Plugins   : no whitelisted plugins (1 plugins total)

Utility:

   cordova-res (update available: 0.15.3) : 0.15.2
   native-run (update available: 1.4.0)   : 1.3.1

System:

   Android SDK Tools : 26.1.1 (/Users/vtn2/Library/Android/sdk)
   NodeJS            : v12.19.0 (/usr/local/bin/node)
   npm               : 7.16.0
   OS                : macOS Big Sur
   Xcode             : Xcode 12.5 Build version 12E262

In my experience, I have always built the release APK in Android Studio.
the process is the following.

  1. ionic build
  2. npx cap copy android
  3. npx cap open android, then Android Studio will open.
  4. Menu/Build/Generated Signed Bundle → choose “APK” of two options, and build a release apk.

I hope it will help you.