9

So, I know how to generate the debug hash key with the password of android. I know that for each new device, I need to generate (and upload to facebook) the new hash key.

Now, I am not yet ready to actually be in production, but I'd like to distribute the app to a set of testers that would prefer not to generate hash things on their own. I see references to a non debug hash key:

Next, you will need to generate a Key Hash for the application. For debugging, if using Eclipse, you will want to generate this Key Hash using the Android debug key. When you are ready to publish your app, you will need to generate a Key Hash for your signing keys and update this value in Facebook before your signed app will work.

http://www.techrepublic.com/blog/app-builder/integrate-facebook-logins-in-your-android-app/296

How do you generate this? I've never made a production (signed) app before, is this something to do with that? Is there a downside to signing my app before its done? If it's not, what do I do to let any device run this app with facebook connectivity?

Luís Ramalho
  • 10,018
  • 4
  • 52
  • 67
J.R.
  • 5,789
  • 11
  • 55
  • 78

1 Answers1

12

You can easily generate an own key to sign your application in release mode. See the Android documentation for detailed information: Signing in Release Mode.

Keystore generation example:

$ keytool -genkey -v -keystore my-release-key.keystore
  -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

Then generate the hash for Facebook as you did with the debug key:

$ keytool -exportcert -alias alias_name -keystore my-release-key.keystore
  | openssl sha1 -binary | openssl base64

And finally share your signed apk with your group of testers, that's all.

ottel142
  • 2,016
  • 1
  • 26
  • 37
  • thanks! man, signing the app is more complicated than I thought, but I have to learn it sometime anyways, so may as well be now – J.R. Jan 31 '13 at 20:45
  • @ottel142 SSO is worked perfectly. But when I signed my build, and make release hash key using above method, my SSO fails – Kimmi Dhingra Apr 20 '15 at 10:08
  • @ottel142 Do I need to generate a hashkey everytime I make an update to my app (i.e. I make a new release apk) ? – Want Jun 10 '15 at 21:33
  • 1
    @Want All of your release APKs have to be signed with the same keystore, this is how Google/Android validates you as the developer of the app. The Android Package Manager refuses to install updates signed with a different keystore. So because the key doesn't change, the hash also stays the same. – ottel142 Jun 11 '15 at 09:11
  • @ottel142 Well, I generated the key hash with my keystore and sometimes it works perfectly (login with fb) and sometimes it says Invalid key hash.. I don't know what to do :/ Thank you for the answer – Want Jun 11 '15 at 09:33
  • 1
    @Want Maybe you're sometimes testing with the debug build? Debug builds are signed with a different keystore... – ottel142 Jun 11 '15 at 10:06
  • @ottel142 Yes! My teammate and I are working in parralel on a project that involves FB Login, so do we need to have 1 release key hash and 2 debug key hashes or do we need to sign the app in release version on each build? Thank you very much, sir! – Want Jun 11 '15 at 10:12
  • 1
    @Want I prefer to generate a app-debug.keystore. Then use this one to override the default debug keystore (in build.gradle -> signingConfigs.debug.storeFile) and check it into version control. So after this all team members use the same debug keystore. – ottel142 Jun 11 '15 at 10:26