How to create keystore for Android
A keystore file (.jks) is essential for signing your Android applications before publishing them to app stores such as Google Play.
Prerequisites
- Java Development Kit (JDK) installed
Ensure the JDK is installed on your system. The keytool utility, required to generate the keystore, comes bundled with the JDK.
You can verify installation by running:
keytool -version- Step 1: Open Terminal or Command Prompt
- Windows: Open Command Prompt or PowerShell
- macOS / Linux: Open Terminal
Navigate to the directory where you want to store your keystore file. It’s recommended to keep it in a secure location (for example, a keystores folder).
cd path/to/your/keystoresStep 2: Generate the Keystore File
Run the following command, replacing the placeholder values with your own details:
keytool -genkeypair -alias your_key_alias -keyalg RSA -keysize 2048 -validity 10000 -keystore your_keystore_name.jksParameter Explanation
- -alias – A unique name for the key (you will reference this during signing)
- -keyalg – Encryption algorithm (RSA is recommended)
- -keysize – Key size (2048 is standard for Google Play)
- -validity – Number of days the key is valid (10000 ≈ 27 years)
- -keystore – Name of the keystore file to be created
Step 3: Respond to Keytool Prompts
The keytool utility will ask you to enter the following information:
Keystore Password
- Enter a strong password for your keystore
- Re-enter the password to confirm (characters may not be visible)
Certificate Information
- What is your first and last name?
first_name last_name - What is the name of your organizational unit?
Your department or team name - What is the name of your organization?
Your company name - What is the name of your City or Locality?
Your city - What is the name of your State or Province?
Your state or province - What is the two-letter country code for this unit?
Examples: IN, US, GB - Is the information correct?
Type yes and press Enter to confirm
Step 4: Verify Keystore Creation (Optional)
After the command completes, the .jks file will be created in the selected directory.
To verify its contents, run:
keytool -list -v -keystore your_keystore_name.jksYou will be prompted to enter your keystore password to view the details.
Important Notes*
Security
- Your keystore file is critical for app updates
- Never share it publicly
- Losing the keystore means you cannot update your app on the Play Store
Backup
- Back up the .jks file securely
- Store both the keystore password and key alias password in a secure, redundant location
Validity
- The 10000 validity value sets the key for ~27 years
- This is recommended because the same signing key must be used for all future updates
Google Play App Signing
- Google Play can securely manage your app signing key
- You upload apps using an upload key, reducing risk
- Upload keys can be regenerated if compromised
Your Android keystore is now ready for signing apps and publishing to Google Play.
