Create Ionic 4 Release Build For Android

What is Ionic?

Ionic framework is the free, open-source toolkit for developing high-quality cross-platform apps for native iOS, Android, and the web — all from a single codebase. It allows us to develop UI using famous frameworks, like Angular, Vue.js, React, etc.

Setting up release build for Android platform

Steps 1

Run "npm install" on the root directory.

Steps 2

Add Android platform with CLI.
 
ionic platform add android 

Steps 3

If you are working in a distributed development environment, then make sure to install the required files. Run ionic Cordova prepare command. It will install the platforms and plugins listed in "config.xml".
 
ionic cordova prepare android 

Steps 4

Now, navigate to Platforms/android with the CLI.
 
cd platforms/android 

Create/Copy release signing key store file under platforms/android folder.

Copy the created Key store file for Android applications if you already have one, otherwise generate a key.store file with the CLI and answer all the questions,
 
keytool -genkey -v -keystore YourApp.keystore -alias YourApp -keyalg RSA -keysize 2048 -validity 10000 

Follow the steps suggested in the documentation for Deploying to a Device.

Create/Specify release signing information

Steps 1

Create a file with name "release-signing.properties" under "platforms\android" folder.

Steps 2

Add the below information to this file.
 
key.store=YourApp.keystore key.store.password=<YourApp keystore password> key.alias=YourApp key.alias.password=<YourApp alias password>
 

Create build for application

Now, go back to the root of your Ionic project with the CLI and build a release version,

ionic cordova build android --prod --release 

If the command runs successfully, then you will find release APK under -- APP_Root_Folder\platforms\android\app\build\outputs\apk\release

Reset plugins and platforms

To install or reinstall all Cordova plugins in Package.json with Ionic, run this command on Windows command prompt with administrator privileges:

rd plugins /d/s && rd platforms /d/s && ionic cordova prepare.
 

Conclusion

These are the steps to create a build for Ionic 4 application, and then you can host your application on the Android store.