How create signed apk for android in ionic 3?

Hi, I am going to teach about how to generate signed APK in Android by using ionic.


Step 1:
          First, we want to remove the Cordova plugin in an ionic project. It automatically recreates the plugin while creating the signed APK.
 Please type the following command in the command prompt.
                        $ ionic cordova plugin rm cordova-plugin-console
Step 2:
        Next, we want to generate a release build for Android, we can use the following Cordova CLI command:
                       $ ionic cordova build --release android
Step 3:
      Next, we can find our unsigned APK file in platforms/android/build/outputs/apk and we want to copy the APK and paste it in your project folder.
      Next, we want to set the path for keytool. By this only we can create the signed apk. Please type the following command in the command prompt. ( if keytool is not recognized as an internal or external command.)
                          set PATH="C:\Program Files\Java\jdk1.8.0_111\bin"
    After we set path in command prompt please type keytool.so we can check whether keytool is present.
Step 4:
      Let’s generate our private key using the keytool command that comes with the JDK and type following command.
$ keytool -genkey -v -keystore “app-name”.keystore -alias “alias-name” -keyalg RSA -keysize 2048 -validity 10000
After pressing enter it asking to generate a password and fill out small information what they ask.

Step 5:
    After generating the keytool and to generate the jar signer. To sign the unsigned APK, run the jar signer tool which is also included in the JDK. Please type the following command in command prompt.
$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-“app-name”.apk “alias-name”

NOTE: Here app-name and alias name are taken from the keystore what you are mention in while creating the keytool.
 Step 6:
     Finally, we need to run the zip align tool to optimize the APK. The zip-align tool can be found in /path/to/Android/sdk/build-tools/VERSION/zipalign. For example, on OS X with Android Studio installed, zipalign is in ~/Library/Android/sdk/build-tools/VERSION/zipalign
                 $ zipalign -v 4 “app-name”.apk ”renamed app-name”.apk

Note: if zip align is not recognized as an internal or external command then run the following CLI command
                                 set PATH="C:\Android\sdk\build-tools\24.0.3"

For more clarity:https://yamechanic.com/5oaK
How create signed apk for android in ionic 3? How create signed apk for android in ionic 3? Reviewed by Sudhan on October 03, 2017 Rating: 5

3 comments:

LightBlog
Powered by Blogger.