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 :
- You must have JDK( Java Development Kit) installed.
- Bin folder from installed JDK directory is set to your PATH variable.
First, Install JDK from Oracle website. For those who don’t know how to set Environment variable path, follow these steps:
- Go to My Computer. On the top, Click on System Properties.
- Then Click on Advanced System Settings on the left.
- Then, Click on Environment Variables button on the bottom of the Dialog Box
- 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.
- 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.
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:
- Open Command Prompt.
- Type this command:
keytool -genkey -v -keystore anyname.keystore -alias anyalias -keyalg RSA -keysize 2048 -validity 10000
-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
- Then Enter your password for keystore and other details:
- That’s it ! Your keystore for signing is generated. You can now use this for signing your apps before uploading on Play Store.