How to generate KeyStore for signing your Android Application

Keystore is one major thing that is used for signing your Android apps before uploading on Google play store. After completing app development and compiling the apk, your app is still unsigned. You need to sign it first before uploading on Play Store. This is the last step.

For generating keystore, make sure you already done these thing :

First, Install JDK from Oracle website. For those who don’t know how to set Environment variable path, follow these steps:

  1. Go to My Computer. On the top, Click on System Properties.
    Screenshot_1
  2. Then Click on Advanced System Settings on the left.
    Screenshot_4
  3. Then, Click on Environment Variables button on the bottom of the Dialog Box
    Screenshot_5
  4. Select PATH from System variables and Click on Edit. Then, Press Home button to lead the cursor to the left of the textbox. After that, Enter the path of the bin directory of the JDK and Don’t forget to put a “;” after the path.
    C:\Program Files\Java\jdk1.7.0_51\bin;

    Screenshot_6

  5. Click OK and you’re done

 

Why setting up Environmental Variable PATH?

The reason is that the /bin directory contains all the tools that is required for compilation of java development programs. By setting this, we can access those programs from any directory.

Generating Keystore

Once the path is set, all we need is program Keytool from the JDK bin directory that is used for generating Keystore. Follow these steps:

  1. Open Command Prompt.
  2. Type this command:
    keytool -genkey -v -keystore anyname.keystore -alias anyalias -keyalg RSA -keysize 2048 -validity 10000

    It meant:

    -genkey : Generate a key pair (public and private keys)
    -v : Enable verbose output.
    -alias <alias_name> : An alias for the key. Only the first 8 characters of the alias are used.
    -keyalg <alg> : The encryption algorithm to use when generating the key. Both DSA and RSA are supported.
    -keysize <size> : The size of each generated key (bits). If not supplied, Keytool uses a default key size of 1024 bits. In general, we recommend using a key size of 2048 bits or higher.
    -keypass <password> : The password for the key. As a security precaution, do not include this option in your command line. If not supplied, Keytool prompts you to enter the password. In this way, your password is not stored in your shell history.
    -validity <valdays> : The validity period for the key, in days. Note that value of 10000 or greater is recommended

    Screenshot_2

  3. Then Enter your password for keystore and other details:
    Screenshot_3
  4. That’s it ! Your keystore for signing is generated. You can now use this for signing your apps before uploading on Play Store.