Trying to create an android app with Facebook integration, I've gotten to the part in the docs where you have to generate a key hash file, it specifies to run the following code
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore
| openssl sha1 -binary
| openssl base64
When I run this in my terminal I get an error for Keystore tampered with or password was incorrect,
I just want to generate my Key Hash
Can anyone point me in the right direction?
One line solution to generate for facebook
Try passing the password for the key and store as part of the command
If you are releasing, use the keystore you used to export your app with and not the debug.keystore.
use this in kotlin for print key hash in log
UPDATED ANSWER (Generating through code) Simpler method :
In my experience, openssl always being troublesome, I tried the second method suggested by facebook. And it's wonderful. This is the best method to get the hash key.
Second option is to print out the key hash sent to Facebook and use that value. Make the following changes to the onCreate() method in your main activity:
Replace com.facebook.samples.loginhowto with your own package name ( package name in Manifest.xml).
Official link - https://developers.facebook.com/docs/android/login-with-facebook/ ( See the bottom of the page)
OLD ANSWER (Generating Keyhash using openssl )
openssl
folderopenssl
folder inC:
drivebin
ofopenssl
i.eC:\openssl\bin
in command promptrun the following command to generate your keyhash. While generating hashkey it should ask you password.
keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Anhsirk.android\debug.keystore" | openssl sha1 -binary | openssl base64
NOTE: in the above code note that , you need to give your path to user ( i.e in my case it is C:\Users\Anhsirk , you just need to change this for your user account.
. If it don’t ask for password your keystore path is incorrect.
If everything works fine, it should give you the hashkey below.
The password of the debug certificate is android and not Android