A simple tutorial for creating a .jks file using Keytool — with fixed passwords, alias, and automated command
Android developers often rely on Android Studio to generate a signing keystore for their apps. But what if you want to create a .jks file without opening Android Studio?
Maybe you're working on a server, CI/CD pipeline, or a lightweight development environment where Android Studio isn't installed.
This guide walks you through:
- Installing the JDK (if missing)
- Enabling the
keytoolcommand - Generating a
.jkskeystore non-interactively - Using fixed credentials (storePassword, keyPassword, alias)
- Creating a matching
key.propertiesfile
Let’s get started.
1. The Goal (What We Want to Generate)
We want a .jks file named:
goalkings.jks
With these credentials:
storePassword = goalkings
keyPassword = goalkings
keyAlias = goalkings
storeFile = goalkings.jks
And we want to generate it using a single command, without Android Studio, without answering prompts.
2. Checking If keytool Works
Before generating the keystore, we must ensure that Java’s keytool utility is available.
Open PowerShell or CMD and run:
keytool -help
If you get:
The term 'keytool' is not recognized...
…it means the JDK isn't installed or not added to PATH.
Let's fix that.
3. Install the Java Development Kit (JDK)
If Java isn’t installed, download and install a JDK:
- Adoptium (recommended): https://adoptium.net
- Oracle JDK: https://www.oracle.com/java/technologies/javase-downloads.html
During installation, note where the JDK is installed. Usually:
C:\Program Files\Java\jdk-17\
or:
C:\Program Files\Java\jdk-21\
4. Add JDK to PATH (Windows)
If you installed Java but keytool still doesn’t work, you need to add it to your PATH.
Steps:
- Press Win + S → search Environment Variables
- Open Edit the system environment variables
- Click Environment Variables
- Under System Variables, find Path → click Edit
- Add the JDK’s
bindirectory:
C:\Program Files\Java\jdk-17\bin
- Click OK
- Restart CMD/PowerShell
Now run:
keytool -help
If it outputs help text — you're ready!
5. Generate the JKS File (Non-Interactive Command)
Navigate to your project directory. Example:
cd D:\vscodeProjects\goalkings
Now run this command exactly:
keytool -genkeypair -v -keystore goalkings.jks -storepass goalkings -keypass goalkings -keyalg RSA -keysize 2048 -validity 10000 -alias goalkings -dname "CN=Goalkings, OU=IT, O=Goalkings Ltd, L=Nairobi, S=Nairobi, C=KE"
✔ No prompts
✔ No questions
✔ Generates goalkings.jks instantly
Your keystore will now appear inside the current directory:
D:\vscodeProjects\goalkings\goalkings.jks
6. Verify the Keystore
Check that everything was created correctly:
keytool -list -v -keystore goalkings.jks -storepass goalkings
This displays:
- alias name
- fingerprints
- key algorithm
- creation date
7. Create a key.properties File (Android)
Inside your Android project root, create:
key.properties
storePassword=goalkings
keyPassword=goalkings
keyAlias=goalkings
storeFile=goalkings.jks
This file is used by your build.gradle for signing.
8. Example build.gradle Signing Setup
Inside:
android {
...
}
Add:
def keystoreProps = new Properties()
def keystorePropsFile = rootProject.file("key.properties")
if (keystorePropsFile.exists()) {
keystoreProps.load(new FileInputStream(keystorePropsFile))
}
android {
signingConfigs {
release {
storeFile file(keystoreProps['storeFile'])
storePassword keystoreProps['storePassword']
keyAlias keystoreProps['keyAlias']
keyPassword keystoreProps['keyPassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
}
}
}
Final Thoughts
You have now:
✔ Installed Java
✔ Enabled keytool
✔ Generated a .jks keystore without Android Studio
✔ Used predefined passwords & alias
✔ Created a key.properties file
✔ Configured signing in Gradle
This method works perfectly for:
- CI/CD pipelines
- Server builds
- Flutter projects
- React Native Android builds
- Lightweight development setups
Top comments (0)