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.

JoJo
  • 19,587
  • 34
  • 106
  • 162

16 Answers16

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

sth
  • 222,467
  • 53
  • 283
  • 367
Sarker
  • 922
  • 7
  • 16
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

Ulrich Dangel
  • 4,515
  • 3
  • 22
  • 30
14

Access denied because you are not an admin.

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

GhostCat
  • 137,827
  • 25
  • 176
  • 248
vivek
  • 541
  • 5
  • 8
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.

Giuseppe Cardone
  • 5,323
  • 2
  • 24
  • 30
  • 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". – peresisUser Sep 13 '16 at 16:04
4

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

pureevill
  • 69
  • 3
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!

sf-in-sf
  • 11
  • 1
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?

Matt
  • 74,352
  • 26
  • 153
  • 180
Yusuf Adeyemo
  • 389
  • 3
  • 12
1

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

Abaid Ullah
  • 36
  • 1
  • 5
1
  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"
Mounir bkr
  • 1,069
  • 6
  • 6
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.

Community
  • 1
  • 1
arnaudweb
  • 11
  • 1
0

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

Nikhil
  • 16,194
  • 20
  • 64
  • 81
Jimmy
  • 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 '13 at 19:27
0

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

fredy
  • 575
  • 2
  • 9
  • 20
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

Vishwani
  • 623
  • 6
  • 8
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!

goRGon
  • 4,402
  • 2
  • 43
  • 45
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 (~).

mherzl
  • 5,624
  • 6
  • 34
  • 75