我正在这里阅读Facebook开发者的开发指南
它说,我必须使用keytool导出签名为我的应用程序,如:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
我不知道如何找到关键工具,以运行它。我试图打开Windows命令提示符并粘贴上述命令,但它不起作用。
我正在这里阅读Facebook开发者的开发指南
它说,我必须使用keytool导出签名为我的应用程序,如:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
我不知道如何找到关键工具,以运行它。我试图打开Windows命令提示符并粘贴上述命令,但它不起作用。
当前回答
KeyTool是JDK的一部分。假设您使用默认设置安装了JDK,您将在$JAVA_HOME/bin中找到它
其他回答
你也可以这样做:
将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
)
Keytool是Java SDK的一部分。你应该能够在你的Java SDK目录中找到它,例如C:\Program Files\Java\ jdk1.6.0_14\bin
获取android密钥哈希码遵循以下步骤(适用于facebook应用)
在此下载windows版的openssl 现在解压缩到c盘 打开CMD提示符 输入cd C:\Program Files\Java\ jdk1.6.0_26\bin 然后只输入keytool -export -alias myAlias -keystore C:\Users\<您的用户名>\。android\myKeyStore | C:\openssl-0.9.8 k_win32 \bin\openssl sha1 -二进制| C:\openssl-0.9.8 k_win32 \bin\openssl enc -a -e 完成
要获得证书指纹(MD5)代码,请遵循以下步骤
去- C:\Program Files\Java\ jdk1.6.0_26\bin 在bin文件夹中运行jarsigner.exe文件 打开CMD提示符 输入cd C:\Program Files\Java\ jdk1.6.0_26\bin 然后再次键入cmd keytool -list -keystore "C:/Documents and Settings/<您的用户名>/.android/debug.keystore" 它现在会要求输入密钥库密码。默认为“android”类型并输入 完成了。
在Windows上
如果你使用Jetbrain的工具箱来管理Android Studio更新,路径是这样的
C:\Users\{USERNAME}\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\202.7486908\jre\bin
更新后,我必须手动更新/设置此路径为JAVA_HOME (jre文件夹)
只需在Windows命令提示符中输入这些。
cd C:\Program Files\Java\jdk1.7.0_09\bin
keytool -exportcert -alias androiddebugkey -keystore "C:\Users\userName\.android\debug.keystore" -list -v
基本密码为android
您将看到MD5、SHA1和SHA256密钥;选择一个你需要的。