0

First, to quote Steve Jobs:

"I am saddened, not by Microsoft's success - I have no problem with their success. (...) I have a problem with the fact that they just make really third-rate products."

JK. Now let's go. I have been just handed over a Xamarin project in my company and I have really no experience with this framework, so I thought someone could enlighten me in some points.

I'm trying to perform a Facebook login in Debug mode in a physical device, but I just can't make the hash key to work. It is throwing the good ol' "Invalid key hash. The key hash xxxxxxxxx does not match any stored ky hashes. etc..." error.

I have done this many times in Android Studio and it always seemed pretty straight forward. I have my appId setup in my AndroidManifest.xml and have added the hashes to Facebook for Develops Dashboard. Now I'm following Facebook's tutorial on key hashes, but no matter what I do the key hash I generate is always different from to one showing in my device.

I'm in a Mac using Visual Studio for Mac 7.5. First I tried generating the hash using ~/.android/debug.keystore, but no success. On further research, I found that Xamarin actually uses another debug.keystore located in ~/.local/share/Xamarin/Mono for Android/debug.keystore, also the same error. Another curious things I noticed is if I use different password it gives me different hashes.

Searching a little more, I discovered that there is a way to generate the keys programmatically using the class PackageManager but, since I'm in Xamarin I'm having a hard time figuring it out. I can't find the Xamarin equivalent of PackageManager.GET_SIGNATURES.

Now for the questions:

  1. Why my device hash is different from the ones I generate in my Mac? From Facebook's docs I understood that if the keystore files used to created the hash and to build my app are the same, the hash key should be the same.

    • Maybe I'm using the wrong password? If so, how can I change it or find the correct one?

    • Maybe Visual Studio is using a third keystore I'm not aware of? If so, how can I find out which keystore file is being used?

  2. How can make the PackageManager class work in Xamarin? I was taking a look at their docs but I really couldn't figure it out.

Thanks!

EDIT

I was indeed using the wrong password. What worked for me was using the keystore located at ~/.local/share/Xamarin/Mono for Android/debug.keystore with the password android

Thiago Loddi
  • 2,212
  • 4
  • 21
  • 35

1 Answers1

1

You can find extensive info about the default (debug) keystore used by Visual Studio both on Mac and Windows in the official doc. You can see the aliases and the passwords in the keytool command example.

Are you building the app for device with a Release build? That could explain a different keystore file being used, depending on the project configuration. What I have seen in the past when I tried to generate a hash for Facebook and it didn't work was that I actually entered the wrong password when prompted for it. If you follow the Facebook instructions, you are basically piping together several commands and then hash the output. The output of the process can actually be "invalid password", which then you base64 hash, and at first might seem like a valid hash, but it isn't.

Gabor Furedi
  • 171
  • 5