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.

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

Password = " 123456 "


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]:  Stephen Sea
    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. Note that some versions of the documentation say that -keyalg is optional with -genkey, and others say it is mandatory.

    Apparently, some people are encountering this error because they are copying this example from the Oracle tutorial on Java Security. It appears that the example was written for older versions of keytool where -keyalg is optional.