开发者

Access denied when creating keystore for Android app

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?

Access denied when creating keystore for Android app

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.File开发者_如何转开发NotFoundException: 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.


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


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


Access denied because you are not an admin.

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


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.


opening Command Prompt as a Administrator helped me.(For Windows 8.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.


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!


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?


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


  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"


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


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


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


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!


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"


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜