Android key hash for Facebook App
Its pretty confusing to get a Key hash value for creating Facebook Apps for Android.
Here are the detailed steps for doing that-
1. We need to download openssl from Google code (64 bit users must download openssl-0.9.8e X64, not the latest version)2. Extract it.
create a folder- OpenSSL in C:/ and copy the extracted code here.
3. Detect debug.keystore file path.
If we can't find one, then lets do a search in C:/ and we will use the Path in the command in next step.
4. Detect keytool.exe path and go to that dir/ in command prompt and run this command in 1 line-
> keytool -exportcert -alias androiddebugkey -keystore "C:\Documents and Settings\Administrator\.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary |"C:\OpenSSL\bin\openssl" base64
Now, it will ask for password, put android
That's all. It will return a key-hash.
Please post a comment, in case of any issue.
it tells me -exportcert is not recognized as an internal or external command
ReplyDeleteHi aggrey,
Deleteinstead of just 'keytool' in the command; try with the whole path to the keytool.exe. For e.g-
> c:/path/to/keytool -exportcert -alias androiddebugkey...
(Sorry if you can't understand me, i dont speak very well)
ReplyDeleteThanks for this, but i have a problem, i can get the h ask key, and i put that in my aplication in facebook developer, but i make the apk and i install in my cellphone, but i can't login whin facebook (i get a FacebookError), can you help me?
uninstall your facebook app on your mobile you'll see that it works
DeleteHi! Thanks for exampe.
ReplyDeleteBut i have a question : where i can get keytool.exe ?
Hi Riddler,
Deletekeytool.exe is in the 'bin/' directory within JRE installation folder.
Something like- C:\Program Files\Java\jre7\bin
or simply do a search.
This comment has been removed by the author.
ReplyDeletei almost getting all things right but at last step it is surly ask for password for every system..? i have ask for the password as following your steps.....
ReplyDeleteplease tell me....thanks
Ya. I think, u r putting a wrong commend. Follow these steps then-
Delete1. Please put the entire command in 1 line.
2. Regenerate 'debug.keystore' file; by just deleting it. Then a rebuild of the debug package will create a new one. Use that.
Good job,, i'am succes in http://azhallea.blogspot.com
DeleteHello ,
ReplyDeletei m following ur step for my app. but still its giving key mismatch error plz help me out.
thanks,
Hi Gaurav. Check out this post-
Deletehttp://stackoverflow.com/questions/7979389/android-invalid-key-and-facebook-connect
hola oye me puedes ayudar es que me marca error en sha1-binary
ReplyDeleteme dice que es un comando incalido
Thanks dude...
ReplyDeletethank u very much...
ReplyDeleteIf tgey don`t ask me the password. It`s Ok?
ReplyDeleteya. it might work
DeleteIts working and asking for password but not provide me any keyhash. what i am doing wrong here
ReplyDeleteThank you so much...
ReplyDelete... is not recognized as an internal or external commands, operable program or batch files
ReplyDelete...seems you r not in correct keytool.exe directory. You have to go inside that directory and then run the command.
Deleteso before the command, u need to 'cd' to keytool path
for e.g-
c:/Users/UserA>cd c:/path/to/keytool/
c:/path/to/keytool>keytool /?
^ it should return command details, here u can run the above command
This comment has been removed by the author.
ReplyDeletesays access is denied
ReplyDeleteThanks man. You saved me a lot of trouble. Keep posting more.
ReplyDeleteHow to get key hash for publishing the application.Please help.
ReplyDeletehow to get debug.keystore to generate the hash key. Is it the same keystore that we use for phonegap release version?
ReplyDeleteI tried generating hash key with that, every time i try to make facebook login with my android device, it says "Invalid android_key parameter, the key *********** does not match any allowed key."
kindly Help. Thank you
thanks, it helped me in getting hash key.
ReplyDeletehello sir,i have tried as per your command mentioned above but it's give me output like.. The system cannot find the path specified. what is wrong with it..
ReplyDeleteso, there should be a path problem. It couldn't find either keytool or openssl or debug.keystore file. 1. for keytool.exe & openssl, simply search & double check the paths, you needto go into the keytool.exe directory & run commends from there. For e.g-
Deletec:> cd c:/path/to/keytool
c:/path/to/keytool> RUN THE COMMAND HERE
hello i have got hash key using this command keytool -exportcert -alias androiddebugkey -keystore "C:\Users\ViralThakar\.android" | openssl sha1 -binary | openssl base64 but it 's not asked me for password and generate key so, it's right key or not.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHey, maybke I'm very late with my comment, but the keytool didn't ask for a password. Is this normal? I still got a hash key.
ReplyDelete(Sorry 4 my bad english, it's not my mother tongue)
Hey I able to create hash but thank to u, but where do I search for the .keystore file I have to link it to unity3d ty
ReplyDeletehi im new to android, i successfully created the hash key and also registered my project in facebook developer page. for first time it works perfectly. but if i again run my app means new hash key is generated and its showing me invalid hash key
ReplyDeletedoes development hash key changes continuosly? how can i manage this scenario. Thank in advance.
Deletelet follow the following code to generate key hash
Deletejust replace your pakage name in code with your own pkg name
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Add code to print out the key hash
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.facebook.samples.hellofacebook",
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 (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
...
This comment has been removed by the author.
ReplyDeletehai,am enter the fellowing steps but it should not ask any password..it show the hask key value.i am confused is it correct or not???
ReplyDeleteMicrosoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:\Users\ADMIN>C:\Users\ADMIN\.android
'C:\Users\ADMIN\.android' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\ADMIN>cd C:\Program Files\Java\jdk1.7.0_79\bin
C:\Program Files\Java\jdk1.7.0_79\bin>keytool -exportcert -alias androiddebugkey
-keystore "C:\Documents and Settings\Administrator\.android\debug.keystore" | "
C:\OpenSSL\bin\openssl" sha1 -binary |"C:\OpenSSL\bin\openssl" base64
Yed1QQfdAJf6lH2TleFWgVbRraY=
C:\Program Files\Java\jdk1.7.0_79\bin>
C:\Users\Admin\.android>keytool -exportcert -alias androiddebugkey -keystore "C:
ReplyDelete\Users\user.android\debug.keystore" | "C:\openssl\openssl-0.9.8k_X64\bin\openssl
" sha1 -binary | "C:\openssl\openssl-0.9.8k_X64\bin\openssl" base64
The filename, directory name, or volume label syntax is incorrect.
i face this error how to solve it??
thanks its working. But 1 thing I want to know "Are key hash character vary with the project or these are same for all project in 1 PC ?"
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteIs it possible to use Unix,Facebook - How we can take Release hashkey
ReplyDeleteIt is not asking for password.but asking for an keystore argument. I am having trouble getting the hash key..plz help me out..
ReplyDelete(Command option -keystore needs an argument.)
useless
ReplyDeleteI got the development hash key by this method thanks. But how do I get the release hash key?
ReplyDeletei used this command
`keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64`
but as i have space in the dir name it shows error, is there any other way to find it? like by Gradle/android/tasks/android/signingReport?
Cool and that i have a tremendous offer: How To House Renovation cost to renovate entire house
ReplyDelete