'how to do prod build in ionic capacitor

In ionic 4, how to do a release aka prod build?

The angular part can be build in prod mode by ionic build --prod

Now how to copy this build to android? If I do ionic capacitor run android it will do normal build first and then copy assets to android. But I want to build in prod mode and take assets to android.

(I know how to generate apk in Android studio)



Solution 1:[1]

After doing ionic build --prod

Assuming you have already installed Capacitor, otherwise you can follow this and thereafter, You can do the following

npx cap copy android

Which copies the built code to android folder.

Then you can do

npx cap open android

Which opens android studio if you havent opened it already, then you should go to Build -> Generate Signed Bundle / APK option and the rest is quite straightforward.

enter image description here

More info can be found here

Solution 2:[2]

You can use the simple way.

ionic capacitor build android --prod

after the command, the android studio will open automatic

Development: android stdio: Build-> Build Bundle(s)/APK(s)->Build APk(s)

Production: android stdio: Build-> Generate Signed Bundle(s)/APK(s)-> Android App Bundle or APk-> release

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Athif Shaffy
Solution 2