0

i am new to the development of facebook so i am trying to build an android application with connection with the facebook and i read the starting facebook SDK for the android development and i download the facebook SDK and when it come to the facebook developer webiste i created the app in the Native android app where i need the key hash

the problem is in the extracting of the key hash where the CMD in on windows 7 display an error message :

'keytool' is not recognized as an internal or external command operable program or batch file.

the command is:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

can anyone help me ?

i will appreciate any help

LebDev
  • 367
  • 3
  • 9
  • 22

2 Answers2

1

Check that the directory the keytool executable is in is on your path.

(For example, on my Windows 7 machine, it's in C:\Program Files (x86)\Java\jre7\bin folder.)

Mr Roshan Pawar
  • 5,267
  • 4
  • 28
  • 44
Sunil Mishra
  • 3,718
  • 1
  • 24
  • 38
  • @ Sunil Mishrai checked and the path of the executable keytool is C:\Program Files\Java\jre6\bin is their any error with this ?? – LebDev Sep 19 '13 at 09:45
  • you can set the it using `path` command e.g. `path "C:\Program Files\Java\jre6\bin"` – Sunil Mishra Sep 19 '13 at 09:47
  • so what is the command that i must write it in the cmd can you give me the finale command ? – LebDev Sep 19 '13 at 09:50
  • i followed the steps as it say but still give me the same error message about keytool – LebDev Sep 19 '13 at 10:00
  • 1. Type `path "C:\Program Files\Java\jre6\bin"` in cmd 2. type `keytool` to check if keytool has been added. 3. Run your command to generate fb hash – Sunil Mishra Sep 19 '13 at 10:36
0

if printing it in app isn't an issue you can run this code to display it

    try {
        PackageInfo info = getPackageManager().getPackageInfo("my.package.name", PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md;
            md = MessageDigest.getInstance("SHA-1");
            md.update(signature.toByteArray());
            Log.e("hash key", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    } catch (NameNotFoundException e1) {
        Log.e("name not found", e1.toString());
    } catch (NoSuchAlgorithmException e) {
        Log.e("no such an algorithm", e.toString());
    } catch (Exception e) {
        Log.e("exception", e.toString());
    }
Ivo Beckers
  • 2,702
  • 14
  • 18
  • @ Ivo Beckers what i need is to get the key hash before i create the app but thank you for your help – LebDev Sep 19 '13 at 10:24