DEV Community

Cover image for 🔥 How to Generate a JKS Keystore Without Android Studio (Complete Guide)
K-kibet for Codespear

Posted on

🔥 How to Generate a JKS Keystore Without Android Studio (Complete Guide)

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 keytool command
  • Generating a .jks keystore non-interactively
  • Using fixed credentials (storePassword, keyPassword, alias)
  • Creating a matching key.properties file

Let’s get started.


1. The Goal (What We Want to Generate)

We want a .jks file named:

goalkings.jks
Enter fullscreen mode Exit fullscreen mode

With these credentials:

storePassword = goalkings
keyPassword   = goalkings
keyAlias      = goalkings
storeFile     = goalkings.jks
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

If you get:

The term 'keytool' is not recognized...
Enter fullscreen mode Exit fullscreen mode

…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:

During installation, note where the JDK is installed. Usually:

C:\Program Files\Java\jdk-17\
Enter fullscreen mode Exit fullscreen mode

or:

C:\Program Files\Java\jdk-21\
Enter fullscreen mode Exit fullscreen mode

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:

  1. Press Win + S → search Environment Variables
  2. Open Edit the system environment variables
  3. Click Environment Variables
  4. Under System Variables, find Path → click Edit
  5. Add the JDK’s bin directory:
C:\Program Files\Java\jdk-17\bin
Enter fullscreen mode Exit fullscreen mode
  1. Click OK
  2. Restart CMD/PowerShell

Now run:

keytool -help
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

✔ No prompts
✔ No questions
✔ Generates goalkings.jks instantly

Your keystore will now appear inside the current directory:

D:\vscodeProjects\goalkings\goalkings.jks
Enter fullscreen mode Exit fullscreen mode

6. Verify the Keystore

Check that everything was created correctly:

keytool -list -v -keystore goalkings.jks -storepass goalkings
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

This file is used by your build.gradle for signing.


8. Example build.gradle Signing Setup

Inside:

android {
    ...
}
Enter fullscreen mode Exit fullscreen mode

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
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

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)