0

I am finishing an app that uses the Android Facebook SDK, in order to login with Facebook. My app must be configured with the proper generated key hash, that must exist on my computer and that must also be set into my Facebook developper console.

When I print the current key hash from my Android app, using the piece of code found on other similary stackoverflow posts, it logs me an old keyhash that I used by the past into my Facebook Developper console. It may be the debug keyhash.

Now I try to generate a release keyhash with the keytool command. As I am working on a Mac :

keytool -exportcert -alias MyReleaseKey -keystore ~/.android/myreleasekey.keystore | openssl sha1 -binary | openssl base64

I tried almost everything, but this command never asks me for a password, and the file is never generated. Some people says that if it isn't asking for a password, then the entered path may be invalid. So, I tried all paths, and all the things I could find on internet, such as deleting the ~/.android/debug.keystore which is generated by Android studio. Nothing works...

Why can't I generate my release keyhash ? Does it have to be stored into the ~/.android/ folder ? I know that when generating the debug keyhash, we must enter the "android" password as the keystore password. Can I enter the password I want for the release keystore ?

Scaraux
  • 2,830
  • 1
  • 27
  • 53

1 Answers1

2

and the file is never generated.

Why do you expect a file to be generated? That command is simply supposed to output a string you then paste into the Facebook dev console.

How do you generate your release APK? Look into app/build.gradle or go to Build -> Generate Signed APK inside of Android Studio and look for the path of your keystore file (it could end with .keystore or .jks).

For now, simplify the command to generate the APK until you're certain you've found the path. Using only

keytool -exportcert -alias MyReleaseKey -keystore ~/.android/myreleasekey.keystore

won't mask any errors, and tell you exactly what's wrong.

Martin Konecny
  • 50,691
  • 18
  • 119
  • 145
  • Oh, I thought the keytool command would generate a file... What path must I give to the keytool then ? I thought giving the path I wrote on my question would create a file named myreleasekey.keystore... So when you say "look for the path of your keystore file", which keystore file are you talking about ? – Scaraux Dec 28 '15 at 23:46
  • No it's trying to read your release key file, read it, and create a hash of it. You just have to make sure that file you are pointing to exists. See the second paragraph of my answer for how to find this release key file - this is assuming you've already created this file (if you previously submitted your app to the Google Play store, then the answer is definitely yes). – Martin Konecny Dec 28 '15 at 23:48
  • Ohh okay. I mixed up EVERYTHING... Thanks for the help ! – Scaraux Dec 28 '15 at 23:51
  • Now, it asks me to enter the password. I entered the path to my .jks file I generated with Android Studio. I have no more errors. But why the printed hash is different than the one that my Apps logs me ? – Scaraux Dec 29 '15 at 00:04
  • "different than the one that my Apps logs me" - plz elaborate – Martin Konecny Dec 29 '15 at 00:05
  • I used a piece of code in my app to print out what keyhash the app is using... see http://stackoverflow.com/questions/5306009/facebook-android-generate-key-hash This piece of code logs a different keyhash than the keytool command I ran on my terminal. It should print the same, right ? – Scaraux Dec 29 '15 at 00:11
  • Are you running the release version of your app when you log that hash? – Martin Konecny Dec 29 '15 at 00:14
  • Oh I see I am stupid. I must run from the signed APK if I want to see the right release keyhash... It should be OK – Scaraux Dec 29 '15 at 00:16