Search code examples
javaandroidcmdkeytool

keytool error: java.lang.Exception: The -keyalg option must be specified


I was generating my android app certificate in Windows 10 Administrator, this was the command I entered to generate the certificate for my app.

keytool -genkey -v -keystore c:\my-release-key.keystore -alias omar

Also as in the image you can see the error. But sorry for that but I am new to Android and this is a first time I was creating a certificate. Help is much appreciated.

The error is keytool error: java.lang.Exception: The -keyalg option must be specified

Password = " 123456 "

This question has been answer by Stephen. Thank you.


Solution

  • Like the error message in your screenshot says.

    The -keyalg option must be specified.

    The following works for me:

    $ keytool -genkey -keyalg RSA -v -keystore foo.jks -alias smith
    Enter keystore password:  
    Re-enter new password: 
    What is your first and last name?
      [Unknown]:  steve
    What is the name of your organizational unit?
      [Unknown]:  here
    What is the name of your organization?
      [Unknown]:  there
    What is the name of your City or Locality?
      [Unknown]:  here
    What is the name of your State or Province?
      [Unknown]:  there
    What is the two-letter country code for this unit?
      [Unknown]:  AU
    Is CN=steve, OU=here, O=there, L=here, ST=there, C=AU correct?
      [no]:  yes
    
    Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 90 days
        for: CN=steve, OU=here, O=there, L=here, ST=there, C=AU
    [Storing foo.jks]
    

    For more information, please refer to the Oracle KeyTool Documentation.