Thursday 14 November 2013

Invalid android_key parameter - Facebook login | Android Facebook hash key error

Hello Droid Friends,
Today , I stuck in Facebook login Issue. I am doing facebook login in my android
application but I am getting following error:

Invalid android_key parameter. The key 26gUhN_wYCwwxenlSneyTeCY
does not match any allowed key. Configure your app key hashes at

I followed following steps:
1. downloaded openssl from here and set it in your system environment path.
2. Uses following command to generate hashkey on my pc.
      keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Acer\.android\debug.keystore"
                                 | openssl sha1 -binary | openssl base64

3. Then I created a new Facebook app  and also added the generated hashkey.

4. I got the Facebook App Id Which I am now using in my and application.

After following all above steps , still I am facing the error "Invalid android_key
parameter" . Then I go to the facebook developer site and find few new things which
comes in Facebook SDK 3.5. And Its helps me in fixing the above "Invalid android_key
parameter" Issue. There Are Two way:

Step-1. When you get this error, check the logcat it returns you a different hashkey,
so you just need to replace the previous hashkey with this one. If you did not getting
any hashkey in logcat error then step-2 helps you.

Step-2: I think this is the best way of generating hashkey bcoz it removes the dependency
of debugkeystore.No need to copy and paste the same debugkeystore on each developer
machine.Here we generate hashkey on the basis of android application package name.
Just used following code for generating the hashkey.

try  {

      PackageInfo info = getPackageManager().
           getPackageInfo(this.getPackageName(), PackageManager.GET_SIGNATURES);

      for (Signature signature : info.signatures) {

          MessageDigest md = MessageDigest.getInstance("SHA");
          Log.d("====Hash Key===",Base64.encodeToString(md.digest(), 
                   Base64.DEFA  ULT));


  } catch (NameNotFoundException e) {


  } catch (NoSuchAlgorithmException ex) {



And use this generated hashkey.This will fixed your "Invalid android_key parameter" issue.

Enjoy :)
Happy Coding... :)

Mukesh Kumar

Hi Guys I am from Delhi working as Web/Mobile Application Developer(Android Developer), also have knowledge of Roboelctric and Mockito ,android test driven development... Blogging has been my passion and I think blogging is one of the powerful medium to share knowledge and ideas....


  1. Hello mukesh,
    This is Sravan ,i fallowed the steps as u shown above,but i need little bit clarification that openssl 2.extract it in C: drive 3.then after by taking the path of bin from openssl 4. setup path in environment variables
    is this process right or not please i request you to provide info.and then after from cmd moving to C:\Program Files\Java\jdk1.7.0_21\bin > keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Acer\.android\debug.keystore" | openssl sha1 -binary | openssl base64
    but here it did not prompt me for password....generated appid its working fine from my emulator but its showing same above error wen i test same from my device >so i request you to please provide me information as soon as possible

  2. Hello Sravan,
    1. First check that on your phone the facebook app is updated one or update your facebook app from google play store.
    2.Please follow the step two, generated hashkey using your package name and use that hash key when you creating a facebook app for app id.
    Please let me know if you still getting same issue or not

  3. hello mukesh,
    just now i have updated facebook app from playstore.
    for generating keyhash using packagename as u stated in we need to run everytime in my code or simple by running once we get key hash? pls provide information

  4. Hello Sravan,
    No need to run that code every time just use one time for getting hash key and then use that key , also remove that code after u get the hash key.

  5. Hello Mukesh,
    Sucessfully i have done it thank you very much.but after some days have been past still im seeing "Invalid android_key parameter" error.initally its running very nicely later getting problem.Thanks in advance.



Copyright @ 2013 Android Developers Blog.