Looking for ?

Translate

Best Steps On to sign your android apk for release with Cordova - using command line interface

 Hello everyone, at this stage, we believe that you must have finished building your cordova app, do normal build to test the app in your phone with either any of this command (cordova build android or cordova run android). If you have gotten to this step, say hurray to yourself. 




1. Run below command , 

keytool.exe -genkey -v -keystore yourkeystorename.keystore -alias youraliasname -keyalg RSA -keysize 2048 -validity 20000


NOTE: -validity 20000

This will set the expiration of your signature to more than 50 years. So all together, your command now looks like


NOTE: The above command will generate the example hash: SHA256withRSA and create yourkeystorename.keystore in root folder


Move the yourkeystorename.keystore into below path of yours

PATH: C:\PathToYourRootProject\platforms\android


2. Create a file with a name “release-signing.properties” NOTE the file extension must be ".properties save and move the file into below path:

PATH: C:\PathToYourRootProject\platforms\android

edit the above file and put the below details in it and save

storeFile=/yourkeystorename.keystore

storeType=jks

keyAlias =youraliasname

keyPassword=yourpassword

storePassword=yourpassword


3. Set version release and version code and package name.


Open root config.xml file from root level and edit widget tag having below attributes:-


android-versionCode="50" 

id="com.demo.apprelease"

version="0.2.3"



4. Run below command  to build and create app-release-unsigned.apk file into a release folder


cordova build android --release



5.  Run below Command to sign the app-release-unsigned.apk:


jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA1 -keystore C:\PathToRootProject\platforms\android\yourkeystorename.keystore C:\PathToRootProject\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk youraliasname


NOTE 1: Replace in above SHA256withRSA with your generated in cmd after running the first step command


NOTE 2: If you get error ->  Jarsigner : You must enter a key password

Then use the below command:

jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA1 -keystore C:\PathToRootProject\platforms\android\yourkeystorename.keystore C:\PathToRootProject\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk youraliasname storepass yourPassword

 

6. Run below command to extract out signed apk file:


zipalign -v 4 C:\PathToRootProject\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk C:\PathToRootProject\platforms\android\app\build\outputs\apk\release\yourappname-signed.apk


NOTE: If you get error that zipalign is not recognise as internal / external command in CMD, go to Build Tool of the API you are using(e.g 29.0.0): C:\Users\YOURNAME\AppData\Local\Android\sdk\build-tools\29.0.0

Copy the zipalign.exe and go and paste it into Tools folder: C:\Users\YOURNAME\AppData\Local\Android\sdk\tools





SHARE THIS POST

About Wakabia

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment