Generate New JKS/Keystore
Method 1 - Using Terminal
Run the following command in your terminal
keytool -genkey -v -keystore android/<JKS FILE NAME>.jks -alias <ALIAS NAME> -keyalg RSA -keysize 2048 -validity 10000
Example command:
keytool -genkey -v -keystore android/example.jks -alias example -keyalg RSA -keysize 2048 -validity 10000
Here,
- JKS File Name: example
- Alias Name: example
The command will generate a JKS file in your android directory. The validity of the keystore certificate is set to 10,000 days. If you don't add "-validity <NumberOfDays>
", the default value
will be 90 days.
Note: If you encounter an error like 'Command 'keytool' not found', you'll also receive a suggestion to install keytool. Follow the suggestion and execute the command to install 'keytool'.
After installing keytool, run the 'keytool' command again and complete the process again.
Method 2 - Using Android Studio
Open your Android module. Wait for a while to complete the import process for the 'android' Gradle project.
Open the build menu from the Menu bar and Select Generate Signed Bundle/APK. Choose APK and click Next.
In the resulting dialog, for the Key store path field, choose Create New to open the New Key Store dialog.
When you click on Create New it will open a dialog to choose keystore file.
Choose the path where you want to store your keystore/jks file. In this example we're storing it at android directory of Project.
Just Add keystore filename in File name field.
Add Keystore Password, Key Alias , Alias Password. Add Details in Certificate section then press Ok.
These Keystore File Path,Keystore Password, Key Alias , Alias Password, you've to set in keystore.properties file which will be in android directory of project. If it's not available then just right click on android directory → New → File and name it as 'key.properties'. Then you can perform steps mentioned here