Wednesday, October 18, 2017

Ionic 3 Build Android App - Create apk file which can be installed in an android device

Steps to create an apk file using ionic 3

Step1: Add Platform

$ ionic cordova add platform android

Step 2: Go to platforms/android

$ cd platforms/android

Note: Add the location of the bin folder of the JDK installation in the PATH Environment Variable

Step 3: Generate Keystore file 

$ keytool -genkey -v -keystore some_name.keystore -alias some_name-keyalg RSA -keysize 2048 -validity 10000

You should enter a password during the generation of some_name.keystore. Remember this passoword and keep some_name.keystore in a safe place.

Step 4: Open build.gradle file in platforms/android and search for the section signingConfigs. Make changes as shown below.

signingConfigs {
    release {
        // These must be set or Gradle will complain (even if they are overridden).
        keyAlias = "some_name"
        keyPassword = "your_password" // And these must be set to non-empty in order to have the signing step added to the task graph.
        storeFile = "some_name.keystore"
        storePassword = "your_password"
    }
}


Step 5: Go to your root folder of the project

$ cd ../../

Step 6: Build

$ ionic cordova build android --release

If successful you will get the following message
...
...
BUILD SUCCESSFUL

Total time: 45.593 secs
Built the following apk(s):
        path_root_folder/platforms/android/build/outputs/apk/android-release-unsigned.apk


Step 7: Sign the apk

$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore platforms\android\some_name.keystore platforms\android\build\outputs\apk\android-release-unsigned.apk some_name

Note: Add the location of the Android sdk build tools folder in the PATH Environment Variable.

Step 8: Zipalign

$ zipalign -v 4 platforms\android\build\outputs\apk\android-release-unsigned.apk Some_Name.apk


You will find the generated apk file in the root folder of your project. Generated apk file is now ready to be installed in your android phone.


1 comment:

  1. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.

    ionic training in chennai

    ReplyDelete