Ram Laxman Yadav bio photo

Ram Laxman Yadav

Ruby on Rails Developer

Email Twitter LinkedIn Github Stackoverflow

Hello!

Today I am going to talk about how to make an android build in release mode and sign it to submit on Google play.

Introduction

If you want to make a build to push over google play then you have to follow these steps:

  • Make a build in release mode by running cordova build android --release
  • Create a code signing key for android.
  • Signing that build
  • Verify that your APK is signed
  • Align the final APK package using zipalign.

Now here is the details explanation about above steps:

###Make a build in release mode by running Just go inside your application’s directory and run command

cordova build android --release
#=> This will create an apk named application_name-release.-unsign.apk inside your build directory.
 

###Create a code signing key To create a code signing key run command

 keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
#=> my-release-key.keystore is the name of your keystore file.
#=> alias_name is alias name for your keystore file.
#=> keyalg is algo to code sign.
#=> keysize id the size of key generally it 2048 or bigger than 2048.
#=> validity is validity of key in days.

###Signing release build Now sign your build by running the command

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name
#=> my-release-key.keystore is location of your keystore file with name.
#=> my_application.apk is location of your apk with name.

###Verify apk Run command

 jarsigner -verify -verbose -certs my_application.apk

###Align the final APK package using zipalign Run command

zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk
#=> your_project_name-unaligned.apk is your apk which you signed.
#=> your_project_name.apk is the name of the final signed apk which will be generate after this command

zipalign ensures that all uncompressed data starts with a particular byte alignment relative to the start of the file, which reduces the amount of RAM consumed by an app.

Now you have a android build in released mode. You can upload it to Google play.

Note: Please backup your keystore file because if you lost it then no way to recover it. If you want to upload the new version of an your application over google play then your new apk must be signed by the same key.