Requirements To Make apk in Ionic:
- First of all you will need Android SDK installed on your computer ( While installing please carefully accept all agreements related to SDK in order to avoid some common errors while releasing apk file)
- You also need JDK (java Development Kit)
Steps To Make apk In Ionic :
- First of all go to your ionic project folder.
- Press shift and right click simultaneously . Now you will see open command window here option. Click it. The command window will be opened.
- Now in the command prompt type the following command to add android platform into your project.
ionic platform add android
- Now you can see that, A platform folder is created in the project folder.
- Now to build an apk file, type the following command
Ionic build android --release
- Now it will build an apk file. You can find that apk file at Platforms\Android\Build\Outputs\apk location.
- Remember, By these steps it will make an unsigned apk.
How To Sign The Apk File :
- First of all make sure that keytool is installed on your system. If not then install it.
- Now go to your project folder and open command prompt. Then type the following command.
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
- It will ask you for some basic informations. After completing all informations, it will generate a keystore file which is named as my-release-key.keystore .
- Now sign your apk by entering the following command. Remember keep your previous apk file and keystore file at same folder. Then run the following command.
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name
- After doing everything correctly, it will give u a message that jar signed. Now you can use that apk file everywhere u want.
The method is same for Ionic2 too. So by this way you can build apk files in ionic frameworks.