After finishing my app development and testing phase, I tried to find some good documentation for generating production release of my build APK. When I searched on Google, the first link which landed me on Ionic docs explaining to create production release in Ionic 1. As ionic 2/3 is based on Angular 4 latest component-based technology having a powerful feature called AOT (Ahead of Time). AOT in simple terms reduced the code to level where we have only that much code which is required for our application.
So after spending some time on my research and facing issue while creating a Signed application, here I am going to steps to create Signed App using latest Ionic 3.
So Let’s start without waiting any time.
Here I believe you have build version of your application which we develop using this command
$ionic cordova build android
Suppose we have android-debug.apk
Step 1 – Go to the root of the application folder. Then run following command.
$ionic cordova build android --prod --release
will remove unnecessary code and compress files data to reduce code. –release
to create unsigned apk file (android-release-unsigned.apk
) at location ~platforms\android\build\outputs\apk
For more information on different options, you can visit official docs here
Step 2 – Now we will create a key, which is a keystore file, makes a signed APK file which then we can upload to an app store.
Copy android-release-unsigned.apk in different folder preferred in C drive where you have added JDK keytool.
From folder where you pasted android-release-unsigned.apk open the CMD prompt and run the command
$keytool -genkey -v -keystore ionicdemo.keystore -alias ionicdemo -keyalg RSA -keysize 2048 -validity 10000
You can change name instead of “ionicdemo” above.
NOTE: If you face issue saying key tool found then add %JAVA_HOME%\bin in environment path variable in windows.
Now enter a password and other valid information as asked and keep this keystore file safe.
Step 3 – Next step is to actually Sign App with keystore and alias name “ionicdemo” we just created.
$jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ionicdemo.keystore android-release-unsigned.apk ionicdemo
This will change unsigned to a signed version of APK file which now can be uploaded to Play Store.
Note: Sometimes when we try to install Unsigned application APK file on a real device it shows error “Application Not Installed”. This issue will resolve after performing Step 3.
Let me know if you face any problem or you have any advice. 🙂