32

I am trying to sign my Android app so I can release it in Market. When I generate the keystore, I get an access denied error. How do I fix this?

android keystore selection

This is what I've been trying to do:

  1. Right click project in Eclipse Helios.
  2. Android Tools > Export Signed Application Package.
  3. Click next.
  4. I check "Create new keystore" and realize it does nothing to help me. It still asks for the location of keystore. So I decide to do it the hard way.
  5. Turned off read-only access on C:\Program Files\Java\jdk1.6.0_25\bin and granted the CREATOR OWNER group full control of the folder.
  6. Open command line on Windows 7 64-bit.
  7. Traverse to C:\Program Files\Java\jdk1.6.0_25\bin.
  8. Run keytool.
  9. Got an access denied error.

.

C:\Program Files\Java\jdk1.6.0_25\bin>keytool -genkey -v -alias company -keyalg R
SA -keysize 2048 -validity 10000 -keystore company.keystore
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  John Smith
What is the name of your organizational unit?
  [Unknown]:  Android
What is the name of your organization?
  [Unknown]:  Company
What is the name of your City or Locality?
  [Unknown]:  Albany
What is the name of your State or Province?
  [Unknown]:  NY
What is the two-letter country code for this unit?
  [Unknown]:  US
Is CN=John Smith, OU=Android, O=Company, L=Albany, ST=NY, C=US correct?
  [no]:  yes

Generating 2,048 bit RSA key pair and self-signed certificate (SHA1withRSA) with
 a validity of 10,000 days
        for: CN=John Smith, OU=Android, O=Company, L=Albany, ST=NY, C=US
Enter key password for <veetle>
        (RETURN if same as keystore password):
Re-enter new password:
[Storing company.keystore]
keytool error: java.io.FileNotFoundException: veetle.keystore (Access is denied)

java.io.FileNotFoundException: veetle.keystore (Access is denied)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:84)
        at sun.security.tools.KeyTool.doCommands(KeyTool.java:902)
        at sun.security.tools.KeyTool.run(KeyTool.java:172)
        at sun.security.tools.KeyTool.main(KeyTool.java:166)

Edit:

Everytime I check the folder permissions, I see that it has reverted back to read-only. There were no errors whenever I turned off read-only.

2
  • 5
    I had the same problem. Try to run cmd as administrator. Feb 12, 2018 at 17:31
  • try change the save location
    – Sushil
    Jun 12, 2021 at 8:22

16 Answers 16

76

Below steps worked for me:

  1. Run command prompt as administrator

  2. Unchecked the read only options in C:\Program Files\Java\jdk1.6.0_25\bin This may not be required

  3. keytool -genkey -v -keystore d:\my_private_key.keystore -alias my_key_alias -keyalg RSA -keysize 2048 -validity 10000

Tell it to create it in drive D:.

2
55

It does help you. You have to specify the location of the file that will be generated. For example specify C:\Documents and Settings\loginname\market.keystore

4
  • 6
    and how do you specify this path through cmd? Aug 22, 2015 at 22:22
  • 10
    For cmd users just open cmd as administrator, go to java path and execute the command as normal Feb 26, 2019 at 17:25
  • Confusing though as in keytool docs it describes -keystore as only name of the store not path + name
    – Waleed93
    Oct 13, 2021 at 14:43
15

Access denied because you are not an admin.

Simply open the cmd prompt as an administrator - that worked for me.

9

The keystore that the Android SDK needs access to is not the same of the JDK. You can simply use the "create new keystore" option of the Android wizard and choose any folder you have write access to: the wizard will create there a new keystore. You don't need to use keytool form JDK.

1
  • This should be the easy and only way to create a keystore file. Important thing to remember is to end the filename you choose with ".jks". Sep 13, 2016 at 16:04
5

opening Command Prompt as a Administrator helped me.(For Windows 8.1)

1
  • 1
    That helped me. Thanks
    – sajid
    Jun 18, 2019 at 15:06
2

It does help you when you open a cmd as an administrator.

1
  • <cd "Program Files"> if want to go from C folder to program files Sep 27, 2022 at 15:53
2
  1. run cmd as administrator
  2. go to the file: C:\Program Files\Java\jdk-17.0.5\bin>
  3. type this command:

.\keytool -genkey -alias bootscurity -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore bootsecurityp.12 -validity 3650

  1. check the folder: C:\Program Files\Java\jdk-17.0.5\bin and it will find your key named "bootsecurityp.12"
1

I had the same problem. You need to define your JAVA_HOME environment variable.

Read the "Basic Setup for signing" paragraph of this link : http://developer.android.com/guide/publishing/app-signing.html#setup

It says:

Before you begin, make sure that the Keytool utility and Jarsigner utility are available to the SDK build tools. Both of these tools are available in the JDK. In most cases, you can tell the SDK build tools how to find these utilities by setting your JAVA_HOME environment variable so it references a suitable JDK. Alternatively, you can add the JDK version of Keytool and Jarsigner to your PATH variable.

If you are developing on a version of Linux that originally came with GNU Compiler for Java, make sure that the system is using the JDK version of Keytool, rather than the gcj version. If Keytool is already in your PATH, it might be pointing to a symlink at /usr/bin/keytool. In this case, check the symlink target to be sure it points to the Keytool in the JDK.

1

Fixing the problem on win7 (yuk) without Eclipse: i have the environment variable JAVA_HOME set to ..../JDK1.7.0_03 (android programmed from GLbasic), and i did only 2 things to fix the problem: 1) in the folder ..../Java/JDK1.7.0_03 i removed the "read-only" permission of the /bin sub-folder, which contains keytool.exe. 2) i opened the console "as administrator" (although it's the only account on my win7). then you do cd...JDK / bin, run again keytool.exe, and you get the file nickname.keystore auto-generated in JDK / bin. Once everything is done you could re-assign the "read-only" permission. Good luck!

1

Running eclipse as administrator solve the problem, then type the following:

keytool -genkey -v -keystore NAME-mobileapps.keystore -alias NAMEmobileapps -keyalg RSA -keysize 2048 -validity 10000

Hope it help?

0

chagning read only on windows 7 helped me. don't forget the default password "changeit"

0

If you are using Windows 7, make sure you are running eclipse as an administrator.

1
  • Since I ran it in the command line (the keygen tool) I needed to run the command line as an administrator, after that it worked and I got no more Access denied messages.
    – AgentKnopf
    Jan 14, 2013 at 19:27
0

Make sure there is no other keystore file at this location C:\Program Files\Java\jdk1.6.0_25\bin. If there is, keep it somewhere else and try the command again:

keytool -genkey -v -keystore d:\my_private_key.keystore -alias my_key_alias -keyalg RSA -keysize 2048 -validity 10000

0

Seems that it's easier to accomplish it in command line via keytool and the latest genkeypair approach. I finished up with the following:

keytool -genkeypair -keystore ~/.android/release.keystore -alias <my_alias> -storepass <my_cert_pass> -keyalg RSA

Then I got a set of questions regarding name, organization, location and password for my alias and that was it!

0

If you are on Mac, Add "sudo" at the beginning of your command "keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000"

0

I got this problem running on linux. The solution was to specify the path relative to the root directory (/), rather than relative to home (~).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.