我正在这里阅读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在JAVAC SDK中,所以你必须在包含jns JAVAC的目录中找到它
其他回答
你也可以这样做:
将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是jdk的一部分,它应该是$JAVA_HOME/bin/keytool
JDK自带keytool。如果您正在使用cygwin,那么这可能已经在您的路径上了。否则,您可能会在JDK的bin文件夹中查找。
为了使shell管道(|)正常工作,您可能需要使用cygwin。
只需在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密钥;选择一个你需要的。
在我的例子中,我已经使用ionic cordova build android——prod命令生成了一个APK文件,我需要为已经存在的APK文件获取SHA-1指纹。下面是我如何通过在App目录中运行以下命令来获得它:
Keytool -list -printcert -jarfile app-debug.apk
所以,我基本上在以下应用程序位置运行上述命令:
C:\myApp\platforms\android\app\build\outputs\apk\debug>keytool -list -printcert -jarfile app-debug.apk
这给了我SHA1指纹为:7B:6B:AD:…
希望这能帮助到一些人!