how to create release apk in ionic angular
- Set up your environment: You need to have the latest version of Node.js and the Ionic CLI installed on your system. You can install them using the following command:
npm install -g ionic cordova
- Open a terminal or command prompt in the root directory of your Ionic project.
- Run the following command to generate a production build of your app:
ionic build --prod
4. This will create a production-ready build of your app in the www
directory.
5. Next, run the following command to generate a release APK:
ionic cordova build android --prod --release
6. This command will generate a release APK in the platforms/android/app/build/outputs/apk/release
directory.
7. If this is the first time you’re generating a release APK, you’ll need to generate a keystore file to sign the APK. You can do this by running the following command:
keytool -genkey -v -keystore my-release-key.keystore -alias my-alias -keyalg RSA -keysize 2048 -validity 10000
8. This command will prompt you to enter a password and some other details. Make sure to remember the password as you’ll need it later.
9. Once you have the keystore file, you can sign the release APK using the following command:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore app-release-unsigned.apk my-alias
10. Replace my-release-key.keystore
with the name of your keystore file and my-alias
with the alias you used when generating the keystore.
11 Finally, run the following command to optimize the APK:
zipalign -v 4 app-release-unsigned.apk my-app.apk
This will create a final release APK named my-app.apk
that is ready to be uploaded to the Google Play Store.