I will note first I am very new to java and android development and possible could have missed something simple. I working through the Facebook example "sessionlogin." It works while there is no Facebook app. When I install the Facebook App and try to run the code it fails with the error
UnknownError: ApiException:Key hash BGyx5d0rMOuY9aQqZK4B9q04+no does not match any stored key hashes
The first thing that I concluded was the obvious the keys are not match, but why? I am confused as to why the app would work without and what the difference in the hash key is for the FB app? Does it use my app's key? Does the FB app require a signed app to access its data?
As for the some of the things i have done, I added a snippet of code to output the hash key at the start of the app. In all cases BGyx5d0rMOuY9aQqZK4B9q04+no= was displayed. The app was stuck in debug mode, so I signed and published the app as explained in this solution. In return the hash that I was using was egNzXZN1fDDeK7PNL+QzHDAKUsg= (on FB, returned from the console cmd ln) but the snippet was returning BW0xQ5kipPoWYWWJd1g3yaKCe6M= when the app actually ran.
After reading through dozens of articles and working through about half of those, I've lost lots of time trying to learn what I am doing wrong and I am now, completely clueless. How can get a working example? Am I missing some fundamental configuration?
Details:
The thing that helped me is go to your FB page - Settings - Apps - Remove the app from the list. Change hash key and reinstall fb app and your app. And now it works...
From the troubleshooting section of this guide, add this to your onCreate:
try {
PackageInfo info = context.getPackageManager().getPackageInfo(
"com.mypackage.name",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.e("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
Add the keyHash shown as is. It will be very similar to the one in your error log but with / & - replaced
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With