我完全不明白这个过程。我已经能够导航到Java SDK中包含keytool的文件夹。虽然我一直得到错误openssl不识别为内部或外部命令。问题是,即使我能让它工作,我该做什么,然后做什么?
当前回答
我也遇到了同样的问题,下面是我如何解决它的方法
keytool -list -alias androiddebugkey -keystore <project_file\android\app\debug.keystore>
其他回答
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Add code to print out the key hash
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.facebook.samples.hellofacebook",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
...
保存更改并重新运行示例。检查你的logcat输出是否有类似这样的消息:
D/KeyHash:(936): 478uEnKQV+fMQT8Dy4AKvHkYibo=
将密钥哈希保存在开发人员配置文件中。重新运行示例并验证可以成功登录。
下载open ssl:
然后将openssl\bin添加到路径系统变量中:
我的电脑->属性->高级配置->高级->系统变量->系统变量下查找路径,并将此添加到其结尾: ; yourFullOpenSSLDir \ bin
现在在你的jdk\bin文件夹C:\Program Files\Java\ jdk1.8.0_40\bin上打开一个命令行(在windows上按住shift并右键单击->打开命令行此处),并使用:
keytool -exportcert -alias keystorealias -keystore C:\yourkeystore\folder\keystore.jks | openssl sha1 -binary | openssl base64
并复制它在给出密码后生成的长度为28的数字。
你可以用这个apk
1.first install the app from the Google play store
2.install the above apk
3.launch the apk and input the package name of your app
4.then you will get the hash code you want
为了在你的本地计算机上生成你的密钥散列,运行Java的keytool实用程序(它应该在你的控制台路径上)针对Android调试密钥存储库。默认情况下,在你的home .android目录下)。在OS X上运行:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
Windows操作系统使用:-
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
希望这对你有所帮助
参考开发者facebook网站
this will help newbees also. just adding more details to @coder_For_Life22's answer. if this answer helps you don't forget to upvote. it motivates us. for this you must already know the path of the app's keystore file and password for this example consider the key is stored at "c:\keystorekey\new.jks" 1. open this page https://code.google.com/archive/p/openssl-for-windows/downloads 2. download 32 or 64 bit zip file as per your windows OS. 3. extract the downloaded file where ever you want and remember the path. 4. for this example we consider that you have extracted the folder in download folder. so the file address will be "C:\Users\0\Downloads\openssl-0.9.8e_X64\bin\openssl.exe"; 5. now on keyboard press windows+r button. 6. this will open run box. 7. type cmd and press Ctrl+Shift+Enter. 8. this will open command prompt as administrator. 9. here navigate to java's bin folder: if you use jre provided by Android Studio you will find the path as follows: a. open android studio. b. file->project structure c. in the left pane, click 'SDK location' d. in the right pane, below 'JDK location' is your jre path. e. add "\bin" at the end of this path as the file "keytool.exe", we need, is inside this folder. for this example i consider, you have installed java separately and following is the path "C:\Program Files\Java\jre-10.0.2\bin" if you have installed 32bit java it will be in "C:\Program Files (x86)\Java\jre-10.0.2\bin" 10. now with above paths execute command as following:
keytool -exportcert -alias androiddebugkey -keystore "c:\keystorekey\new.jks" | "C:\Users\0\Downloads\openssl-0.9.8e_X64\bin\openssl.exe" sha1 -binary |"C:\Users\0\Downloads\openssl-0.9.8e_X64\bin\openssl.exe" base64
您将被要求输入密码,请输入您在创建密钥存储库密钥时所提供的密码。 ! ! 这将给你钥匙
错误: 如果你得到: --- 'keytool'不能被识别为内部或外部命令 --- 这意味着Java安装在其他地方。
推荐文章
- 如何解决INSTALL_FAILED_DEXOPT错误?
- 有没有办法自动安装Android SDK ?
- 如何检查一个视图在Android中是否可见?
- 一对多、多对一、多对多的区别?
- Android是否保留。apk文件?如果有,在哪里?
- 从枚举中选择一个随机值?
- 如何从URL获取参数与JSP
- 如何在Eclipse中生成Javadoc注释?
- 找到java类从哪里加载
- 从集合中随机选取一个元素
- 为什么x == (x = y)和(x = y) == x不一样?
- 什么Java 8流。收集等价物可在标准Kotlin库?
- 在Android 5棒棒糖中,通知栏图标变成白色
- 从URI获取真实路径,Android奇巧新的存储访问框架
- 等待未来的名单