我完全不明白这个过程。我已经能够导航到Java SDK中包含keytool的文件夹。虽然我一直得到错误openssl不识别为内部或外部命令。问题是,即使我能让它工作,我该做什么,然后做什么?
当前回答
你可以用这个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
其他回答
Windows:
打开命令提示符并粘贴下面的命令
键盘出口,又名仙女座键盘 HOMEPATH % \调试机器人。keystore | openssl sha1 -binary | openssl base64
输入密码:android——>按Enter键 用你的开发者账号登录Facebook 去你的Facebook应用程序>设置>粘贴哈希键在“键哈希”选项>保存更改。 现在用Facebook登录/分享等测试你的android应用。
你可以从https://console.developers.google.com/projectselector/apis/credentials上获得你所有的指纹 然后使用下面的Kotlin代码将其转换为keyhash:
fun main(args: Array<String>) {
listOf("<your_production_sha1_fingerprint>",
"<your_debug1_sha1_fingerprint>",
"<your_debug2_sha1_fingerprint>")
.map { it.split(":") }
.map { it.map { it.toInt(16).toByte() }.toByteArray() }
.map { String(Base64.getEncoder().encode(it)) }
.forEach { println(it) }
}
在你的应用程序中运行:
FacebookSdk.sdkInitialize(getApplicationContext());
Log.d("AppLog", "key:" + FacebookSdk.getApplicationSignature(this)+"=");
或:
public static void printHashKey(Context context) {
try {
final PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES);
for (android.content.pm.Signature signature : info.signatures) {
final MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
final String hashKey = new String(Base64.encode(md.digest(), 0));
Log.i("AppLog", "key:" + hashKey + "=");
}
} catch (Exception e) {
Log.e("AppLog", "error:", e);
}
}
然后看看日志。
结果应该以“=”结尾。
解是基于这里和这里。
以下是你需要做的
从代码下载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 ->使用GIT BASH!
Keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug。Keystore | openssl sha1 -binary | openssl base64 . Keystore | openssl sha1 -binary
默认密码为“android”
我们大多数人都安装了Git Bash,所以这是我最喜欢的方式。
推荐文章
- 警告: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中的回调函数