我正在这里阅读Facebook开发者的开发指南

它说,我必须使用keytool导出签名为我的应用程序,如:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

我不知道如何找到关键工具,以运行它。我试图打开Windows命令提示符并粘贴上述命令,但它不起作用。


当前回答

这取决于您的Eclipse版本(我使用的是Kepler)。 去Windows>首选项>Android>构建。

您将找到调试密钥库的位置路径以及SHA1指纹(您可以复制并使用它)

其他回答

keytool是JDK的一部分。

尝试将%{JAVA_HOME}\前置到exec语句或c:\{jdk}的路径\bin。

Android:在Android中执行keytool命令的位置

如果在classpath变量中设置了JRE,则可以在dos命令提示符下运行Keytool命令。

例如,如果您想获取android SDK调试证书的MD5指纹,

只需运行以下命令…

C:\Documents and Settings\user\.android>  keytool -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android

C:\Documents and Settings\user\.Android >是包含调试的路径。必须经过认证的密钥存储库。

详情请访问http://code.google.com/android/add-ons/google-apis/mapkey.html#getdebugfingerprint

Few observations while I was getting the same problem (Windows). 1. Shell pipe is important. 2. If you are using OpenSSL or Cygwin, definitely you have to install it. 3. keytool comes with JDK so either you have to point to it in the command or you have cd to the JDK/bin folder (where the exe resides) 4. The debug keystore is typically located at ~/.android/debug.keystore 5. password is "android" whether you -keypass it or type it when prompted. 6. For the alias name, you can open (DO NOT SAVE, just open and close) the keystore file with any editor and read it. 7. MOST IMPORTANT - There is a difference is specifying the keystore path within quotes and without. I got it working by using the keystore path within the double quotes. As remix090378 said and as per the instruction, this command indeed worked - cd C:\Program Files\Java\jdk1.7.0_09\bin

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\userName.android\debug. keystore "密钥存储库" -list -v

你也可以这样做:

将bat文件复制到PATH环境变量中已经存在的任何文件夹中 然后只需在任何Windows shell中使用keytool命令

keytool的实际位置在bat文件中定义。如果位置错误,bat文件将扫描您的系统,以检测ProgramFiles(子)文件夹中的潜在位置。

还可以找到keytool2.bat,这是"keytool -v -list -keystore"的便捷快捷方式,广泛用于快速检查jks文件的内容。

keytool.bat:


:: 
:: 
:: "keytool alias" script by Céphas
:: easy method : add the known keytool.exe folder to your personal PATH variable (run : C:\Windows\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables)
:: else, add the folder containing this bat script to your personal path or put this script in any folder already defined in your path
::
:: also see keytool2.bat that automatically adds the following parameters in the keytool command line : -v -list -keystore, for quick display of jks content
:: 
:: 
@echo off
set THIS_SCRIPT=%~f0
rem  setlocal enableDelayedExpansion : necessary for paths containing special chars
setlocal enableDelayedExpansion

rem  set PATH to keytool.exe ; path must include the final \
rem  ^ is escape char for paths containing & \ < > ^ | 
set PATH_TO=C:\Program Files\Java\jre1.8.0_45\bin\
set PROG_NAME=keytool.exe

rem full_path, with "", to work with paths containing special chars
set FULL_KT_PATH="!PATH_TO!!PROG_NAME!"

rem checks if keytool.exe exists
(dir %FULL_KT_PATH%>nul 2>nul && set KT_FOUND=yes) || set KT_FOUND=no

if %KT_FOUND%==yes (
    rem keytool found => launching it with all supplied parameters
    rem 
    rem
    %FULL_KT_PATH% %*
    rem
    rem
) else (
    rem keytool not found, trying to find it in %ProgramFiles%

    echo.
    echo Keytool not found in expected location, scan in progess ...
    echo.

    cd "%ProgramFiles(x86)%" 2>nul && dir /B /S keytool.exe 2>nul

    cd "%ProgramFiles%" 2>nul && dir /B /S keytool.exe 2>nul

    echo.
    echo *********
    echo Path to program keytool.exe not properly defined, or keytool/java missing on this system
    echo If any location has been found during above scan, fix variable "PATH_TO" in %THIS_SCRIPT% accordingly
    echo *********
    echo.
    pause
    
)    

keytool2.bat:


:: 
:: 
:: "keytool2 alias" script by Céphas
:: easy method : add the known keytool.exe folder to your personal PATH variable (run : C:\Windows\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables)
:: else, add the folder containing this bat script to your personal path or put this script in any folder already defined in your path
::
:: keytool2 automatically adds the following parameters in the keytool command line : -v -list -keystore
:: thus, to quickly display the full content of a jks file, usage is simply : keytool2 \path\to\your\keystore.jks [-alias your_alias]
:: 
:: 
@echo off
set THIS_SCRIPT=%~f0
rem  setlocal enableDelayedExpansion : necessary for paths containing special chars
setlocal enableDelayedExpansion

rem  set PATH to keytool.exe ; path must include the final \
rem  ^ is escape char for paths containing & \ < > ^ | 
set PATH_TO=C:\Program Files\Java\jre1.8.0_45\bin\
set PROG_NAME=keytool.exe


rem full_path, with "", to work with paths containing special chars
set FULL_KT_PATH="!PATH_TO!!PROG_NAME!"

rem checks if keytool.exe exists
(dir %FULL_KT_PATH%>nul 2>nul && set KT_FOUND=yes) || set KT_FOUND=no

if %KT_FOUND%==yes (
    rem keytool found => launching it with all supplied parameters
    rem 
    rem
    %FULL_KT_PATH% -v -list -keystore %*
    rem
    rem
) else (
    rem keytool not found, trying to find it in %ProgramFiles%

    echo.
    echo Keytool not found in expected location, scan in progess ...
    echo.

    cd "%ProgramFiles(x86)%" 2>nul && dir /B /S keytool.exe 2>nul

    cd "%ProgramFiles%" 2>nul && dir /B /S keytool.exe 2>nul

    echo.
    echo *********
    echo Path to program keytool.exe not properly defined, or keytool/java missing on this system
    echo If any location has been found during above scan, fix variable "PATH_TO" in %THIS_SCRIPT% accordingly
    echo *********
    echo.
    pause
    
)    

在Windows上

如果你使用Jetbrain的工具箱来管理Android Studio更新,路径是这样的

C:\Users\{USERNAME}\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\202.7486908\jre\bin 

更新后,我必须手动更新/设置此路径为JAVA_HOME (jre文件夹)