Troubleshooting Facebook Login for Android

Here are errors you may see as a result of problems with the key hash:

  • Native Login Dialog - You get the native Login Dialog permissions, but after that, the person is not authenticated. The logcat contains this exception:

12-20 10:23:24.507: W/fb4a:fb:OrcaServiceQueue(504): com.facebook.orca.protocol.base.ApiException: remote_app_id does not match stored id

  • Non-Native Login Dialog - You see a non-native Login Dialog that includes an error message at the top: ''..App is Misconfigured for facebook login...''.

Open SSL

If you don't have openssl, install it from here: Windows, MAC.

Invalid Key Hash

Here are some resources to troubleshoot this:

  • Key Hash Reference Doc: Signing Your Applications.

  • Invalid Key Hash: The keytool silently generates a key hash regardless of unknown debug.keystore location or wrong password. If you get exceptions or visual cues related to an invalid key hash check the following:

  • Click 'Save Changes' when youn add a key hash to the App Dashboard.

  • The password you entered is incorrect. The default Keystore password: "android".

  • Manually Check Key Hash - You can print out the key hash sent to Facebook and use that value in App Dashboard. Make this change to onCreate() in your main activity:

@Override

public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
                
     try {
         PackageInfo info = getPackageManager().getPackageInfo(
                           "com.facebook.samples.loginhowto", 
                            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) {
                  
          }
           ...

Replace com.facebook.samples.loginhowto with your own package name.

Key Tool

  • Keytool Command Not Found - Keytool comes with the standard Java JDK. If you get ''Command not found'' error, add the path to your global ''PATH'' or go to the folder to run this command:

Windows: C:\Program Files (x86)\Java\jdk1.6.0\bin,

MAC: /usr/bin.

  • Unknown debug.keystore Location - Keytool couldn't find your debug.keystore location. Check for the correct path. Keytool always ask for a password when it has the correct location.