我完全不明白这个过程。我已经能够导航到Java SDK中包含keytool的文件夹。虽然我一直得到错误openssl不识别为内部或外部命令。问题是,即使我能让它工作,我该做什么,然后做什么?
当前回答
Windows:
打开命令提示符并粘贴下面的命令
键盘出口,又名仙女座键盘 HOMEPATH % \调试机器人。keystore | openssl sha1 -binary | openssl base64
输入密码:android——>按Enter键 用你的开发者账号登录Facebook 去你的Facebook应用程序>设置>粘贴哈希键在“键哈希”选项>保存更改。 现在用Facebook登录/分享等测试你的android应用。
其他回答
https://developers.facebook.com/docs/android/getting-started/
4.19.0 - 2017年1月25日
Facebook SDK
修改
Facebook SDK现在在应用程序启动时自动初始化。在大多数情况下,不再需要手动调用FacebookSDK.sdkInitialize()。有关详细信息,请参见升级指南。
为调试
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 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 (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
如果你已经将应用程序上传到Play商店,你可以生成哈希密钥如下:
点击这里进入发布管理 选择“发布管理->应用签名” 你可以看到SHA1密钥十六进制格式的App签名证书。 复制十六进制格式的SHA1,并将其转换为base64格式,你可以使用这个链接做到没有SHA1:十六进制的一部分。 转到Facebook开发者控制台,在设置- > basic - > key哈希值中添加键(转换为base64后)。
以下是你需要做的
从代码下载openSSl 提取它。在C:/目录下创建一个名为OpenSSL的文件夹,并将解压后的代码复制到这里。
检测调试。Keystore文件路径。如果你没有找到,那么在C:/中进行搜索,并在下一步中使用命令中的Path。
检测您的keytool.exe路径,并进入dir/ in命令提示符,并在一行中运行此命令
$ keytool -exportcert -alias androiddebugkey -keystore "C:\Documents and Settings\Administrator.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary |"C:\OpenSSL\bin\openssl" base64
它会要求输入密码,输入android 这是所有。你会得到一个key-hash
OpenSSL:如果你的操作系统没有预安装OpenSSL(例如Windows没有预安装),你就必须安装它。如何安装取决于您的操作系统(对于Windows,请查看coder_For_Life22提供的链接)。
最简单的方法是将openssl.exe二进制文件复制到您的keytool路径(如果您使用的是Windows)。如果不想这样做,则必须将其添加到PATH环境变量中。然后执行文档中提供的命令。
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
注意-keystore后面的参数指向调试密钥库。这个位置也取决于您的操作系统。应位于下列地点之一:
Windows Vista或7 - C:\Users\.android\debug.keystore Windows XP - C:\Documents and Settings\.android\ debug.keystore OS X和Linux - ~/.android/debug.keystore
如果所有操作都正确,系统将提示您输入密码。这是用于调试证书的android。如果密码正确,控制台将输出一个散列(有些随机字符和数字)。
把它复制到android键哈希字段内的首选项你的应用程序在facebook上。要做到这一点,请访问developers.facebook.com/apps,选择你的应用程序,进入编辑设置,向下滚动。之后,等待几分钟,直到更改生效。
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安装在其他地方。
推荐文章
- 警告:API ' variable . getjavacompile()'已过时,已被' variable . getjavacompileprovider()'取代
- 安装APK时出现错误
- 在流中使用Java 8 foreach循环移动到下一项
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 用Java计算两个日期之间的天数
- 碎片中的onCreateOptionsMenu
- 如何配置slf4j-simple
- 在Jar文件中运行类
- 带参数的可运行?
- TextView粗体通过XML文件?
- 如何使线性布局的孩子之间的空间?
- 如何测试Facebook本地连接
- 我如何得到一个字符串的前n个字符而不检查大小或出界?
- 我可以在Java中设置enum起始值吗?
- Java中的回调函数