5

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)

2 Answers2

8

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

Athif Shaffy
  • 692
  • 3
  • 10
  • 22
0

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

Siddhartha Mukherjee
  • 2,703
  • 2
  • 24
  • 29
  • not opening android studio but getting the below error message ionic capacitor build android --prod [ERROR] Unable to find command: capacitor build android – Dr NVS Feb 28 '23 at 03:21
  • 1
    This error message occurs because your project is based on Cordova and not capacitor – Siddhartha Mukherjee Mar 01 '23 at 06:30