无效的键哈希facebook android sdk [英] Invalid Key hash facebook android sdk
问题描述
我正在尝试使用Facebook Android SDK开发一个简单的应用程序与Facebook登录按钮。但是我有麻烦的钥匙哈希。我创建了一个调试键和一个发行键:(在Mac中)
调试键:
keytool -exportcert -alias androiddebugkey -keystore〜/ .android / debug.keystore | openssl sha1 -binary | openssl base64
keytool -exportcert -alias< RELEASE_KEY_ALIAS> -keystore< RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64
我也试过这个代码也是
public static void showHashKey(Context context){
pre>
try {
PackageInfo info = context.getPackageManager()。getPackageInfo(
com.example。我,PackageManager.GET_SIGNATURES); //你的包名是
(签名签名:info.signatures){
MessageDigest md = MessageDigest.getInstance(SHA);
md.update(signature.toByteArray());
Log.i(KeyHash),Base64.encodeToString(md.digest(),Base64.DEFAULT));
}
} catch(NameNotFoundException e){
} catch(NoSuchAlgorithmException e){
}
}
然后我在Facebook Developers页面中复制了这个关键散列。当我用eclipse运行我的应用程序然后工作。但是当我导出apk并将其复制到设备不工作。
我也有另一个问题。如果我的divice已经安装了Facebook应用程序,那么也不工作。
我如何解决我的问题?解决方案当您获得无效的密钥哈希时,它还显示正确的密钥哈希并说键盘XXXXX不匹配任何存储的键盘。所以拷贝显示的keyhash,并在末尾附加=作为XXXXX =,并将其添加到密钥哈希部分。希望它可以工作....
这可能也会工作
public static void showHashKey(Context context){
pre>
try {
PackageInfo info = context.getPackageManager()。getPackageInfo(
com.example.me,PackageManager.GET_SIGNATURES); //你的包名是
(签名签名:info.signatures){
MessageDigest md = MessageDigest.getInstance(SHA);
md.update(signature.toByteArray());
Log.i(KeyHash),Base64.encodeToString(md.digest(),Base64.DEFAULT));
}
} catch(NameNotFoundException e){
} catch(NoSuchAlgorithmException e){
}
}
I'm trying to use Facebook Android SDK to develop a simple app with the Facebook Login Button. But i'm having trouble with Key Hashes. I've created both a debug key and a release key:(in mac)
Debug key:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64
i also tryed this code also
public static void showHashKey(Context context) { try { PackageInfo info = context.getPackageManager().getPackageInfo( "com.example.me", PackageManager.GET_SIGNATURES); //Your package name here for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.i("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } }
And then i copied this key hashes in the Facebook Developers page.when i run my app with eclipse then working.but When i export the apk and copy it into the device it does not working. also i have another problem.if my divice has installed Facebook Application then also not working. how i can solve my problem?
解决方案When you get Invalid key hash, it also shows the correct key hash and says "The keyhash XXXXX didnot match with any of the stored keyhashes" . so copy that displayed keyhash and append "=" at the end as XXXXX= and add it in the key hash section. Hope it works....
this might also work
public static void showHashKey(Context context) { try { PackageInfo info = context.getPackageManager().getPackageInfo( "com.example.me", PackageManager.GET_SIGNATURES); //Your package name here for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.i("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } }
这篇关于无效的键哈希facebook android sdk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!