0

Downloaded recent facebook android sdk 3.7 and i tried to run sample apps in the sdk. When I tried helloFacebookSample app i got hashkey problem. I searched through web and got my hashkey correct i.e DSygOIIJUkYyHy/duT1e72ZHl5U=.

My app is showing "hashkey not stored" error. When I logged my sample app hashkey I found strange thing happening.

I am using this code:

Toast.makeText(getApplicationContext(),Base64.encodeToString(md.digest(), Base64.DEFAULT), Toast.LENGTH_LONG).show();
                Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));

                Toast.makeText(getApplicationContext(),Base64.encodeToString(md.digest(), Base64.DEFAULT), Toast.LENGTH_LONG).show();

Same piece of code is showing different hashkeys

DSygOIIJUkYyHy/duT1e72ZHl5U=

2jmj7l5rSw0yVb/vlWAYkK/YBwk=

and when I try to post status it shows a different hashkey.

DSygOIIJUkYyHy_duT1e72ZHl5U=

I have stored all three hashkeys in my sample app, and it is still showing me this error.

halfer
  • 18,701
  • 13
  • 79
  • 158
  • If you followed this https://developers.facebook.com/docs/android/getting-started it should be the correct. – anuruddhika Mar 11 '14 at 09:33
  • I created a new app on facebook and repeated the same process again. it is working now. But i m still confused why Base64.encodeToString(md.digest(), Base64.DEFAULT) is giving me two different values – user3405271 Mar 11 '14 at 13:04
  • did you get correct hash-Key? – anuruddhika Mar 12 '14 at 04:03
  • Yes I did. I am confused why programmatically Base64.encodeToString(md.digest(),Base64.DEFAULT) when run two time is showing me two different hashkeys. As stated this line provides us hashkey which shall remain same no matter how many times I run this line. But it is showing the original hashkey and then a different hashkey – user3405271 Mar 12 '14 at 06:34

2 Answers2

4

This problem usually comes when hashkey generated by your app doesnt match with the one which you have put in facebook developers site. Try to generate the hashkey programmatically and put it in developers site. Hope this solution helps

Preethi Rao
  • 4,915
  • 1
  • 13
  • 28
1

The same problem occurred to me , i had no idea what gone wrong ,then i realized that that key store that i used to generate the key hash was a different one ,if you have signed your app you will get a .jks key store file ,you have to specify that path of the file in the code generating the key hash like

keytool -list -v -keystore yourkeystore_path/yourkeystore.jks -alias your_aliase_name 

the names of the keystore file and aliases name should be same as the one when you signed your app then your get the correct code for sure.

then there also a work around just write down the code displaying in the error and put it in the keyhash field simple as that...

hope it helps

Ameen Maheen
  • 2,427
  • 1
  • 24
  • 28