GENERATE SIGNED APK IN IONIC

Share the post

How to generate signed APK Ionic V3.

Hello All, If you want to release the android application on google playstore then you must want a signed APK to upload. In this topic we will see the detailed steps to learn about how to generate signed APK ionic. We will build signed APK from unsigned APK step by step. Please follow below steps to generate the signed APK without any error. If you want to learn about Ionic 3 then click here.

Steps to generate signed APK ionic :

1. Open the visual studio code & go to terminal (View –> Terminal) / command prompt in administrative mode

Write the following command:

ionic cordova build android --prod --release

You will find the unsigned apk in following path:
Go to your project :

projectNameHere\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk

Now we got the unsigned APK but to release the APK on google playstore we need to sign it
so, follow below steps to create sign APK

2. Generate private key by using following keytool command:

before that Go to bin folder of Java JDK :

C:\Program Files\Java\jdk1.8.0_201\bin

After that write the following command :

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

replace alias_name with key name like mykey
so your new command will look like this (Note : Make sure command prompt / VS code open in administrative mode)

keytool -genkey -v -keystore my-release-key.keystore -alias mykey -keyalg RSA -keysize 2048 -validity 10000


Press Enter. After that answer the few questions as listed below:

Enter keystore password: ENTER YOUR PASSWORD HERE

Re-enter new password: RE-ENTER YOUT PASSWORD HERE

What is your first and last name?

Unknown:

What is the name of your organizational unit?

Unknown:

What is the name of your organization?

Unknown:

What is the name of your City or Locality?

Unknown:

What is the name of your State or Province?

Unknown:

What is the two-letter country code for this unit?

Is CN=, OU=, O=, L=, ST=, C=91 correct?

Answer above questions

& Press Enter

After that you will find the keystore in following folder :

C:\Program Files\Java\jdk1.8.0_201\bin\my-release-key.keystore

Keep this keystore file which genereated in above step in safe place.

3. Running the jarsigner tool:

Go to following path :

cd C:\Program Files\Java\jdk1.8.0_201\bin

Write below command :

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore app-release-unsigned.apk alias_name
my-release-key.keystore : replace with full path of keystore file
app-release-unsigned.apk : replace with full path of unsigned apk
alias_name : we place the name mykey in above step

after that our new command will look like:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore projectNameHere\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk mykey

after that you have to enter password for keystore file & press enter. You get the message jar signed

4. Optimize the APK by using zipalign tool:
Go to folder of build-tools of android SDK (C:\Users\COMPUTERNAMEHERE\AppData\Local\Android\Sdk\build-tools\28.0.3)

Write following command:

zipalign -v 4 app-release-unsigned.apk app-release-signed.apk

app-release-unsigned.apk : write full path for unsigned apk

after that our new command will look like:

zipalign -v 4 projectNameHere\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk app-release-signed.apk

That’s it. You will find the signed APK on following path :

 C:\Users\COMPUTERNAMEHERE\AppData\Local\Android\Sdk\build-tools\28.0.3

This is how we generate Ionic Cordova build signed APK

Leave a Comment