我正在这里阅读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命令提示符并粘贴上述命令,但它不起作用。
当前回答
你也可以这样做:
将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
)
其他回答
在cmd窗口(需要以管理员身份运行),
cd %JAVA_HOME%
只有在设置了系统环境变量JAVA_HOME后才有效。要为路径设置系统变量,可以这样做
setx %JAVA_HOME% C:\Java\jdk1.8.0_121\
然后你就可以打字了
cd c:\Java\jdk1.8.0_121\bin
or
cd %JAVA_HOME%\bin
然后,执行JAVA jdk提供的任何命令,例如
keytool -genkey -v -keystore myapp.keystore -alias myapp
你只需要按回车键后回答问题(相当于在cmd行上输入值)!密钥将被生成
keytool是JDK的一部分。
尝试将%{JAVA_HOME}\前置到exec语句或c:\{jdk}的路径\bin。
#进入cacerts或jsk所在路径,打开并在cmd下运行以下命令
Keytool -v -list -keystore cacerts
Keytool -v -list -keystore .jks
在Windows上
如果你使用Jetbrain的工具箱来管理Android Studio更新,路径是这样的
C:\Users\{USERNAME}\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\202.7486908\jre\bin
更新后,我必须手动更新/设置此路径为JAVA_HOME (jre文件夹)
Keytool是Java SDK的一部分。你应该能够在你的Java SDK目录中找到它,例如C:\Program Files\Java\ jdk1.6.0_14\bin