3

I am trying to build an android app with Facebook login. The app runs successfully on the emulator. But every time I install and run the app on an Android device and tries to login I get the error as in the following screenshot:enter image description here

Varun
  • 860
  • 2
  • 10
  • 26
azhar
  • 1,591
  • 1
  • 16
  • 36

1 Answers1

0

Your Facebook application should have key hashes that are valid to the keystore you are using the following code:

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

    } catch (NoSuchAlgorithmException e) {

    }  

or follow this link instructions Facebook Android Generate Key Hash

Then add this generated key hash to the keyhashes in android settings in your Facebook application

Community
  • 1
  • 1
Ahmed Zayed
  • 2,115
  • 1
  • 17
  • 20