Question

We know that Facebook SDK integration to Android requires a key hash configuration. Also we can generate keyhash using the following ways. Openssl and Android code suggested by FB. If we use openssl, we should use the keystore we used to export our app with and not the debug.keystore. I'm using the second method to get the keyhash. I'm the developer of my app which will be signed and published from another system by another person. My question is: Where should I execute the below code to get the keyhash? On my (developer) machine or From the machine where we are going to sign and publish? Will the keyhash for my app be different for different machines? Please guide me.

try {
    PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.i("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
    }
} catch (Exception e) {

}
Was it helpful?

Solution

You will also need to associate your Android keys hashes with the app. The key hash is used by Facebook as a security check for authenticity. By default, the app's package is signed with a machine specific debug key. When publishing the app it is typically signed with a different, release key. Therefore, you want to make sure you have the hashes of all the related keys set on Facebook:

Go to 'Settings' in the left nav, then click on the 'Add Platform' button, and select Android. Add the debug key hash that you obtained. You should add multiple keyhashes if you are developing on multiple machines.

OTHER TIPS

Use this code inside oncreate() method and once you get the KeyHash then paste that keyhash to https://developers.facebook.com/ App->Create a new app

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top