2

I am trying to integrate facebook to my brand new android application. But I can't make it through the tutorial provided by facebook. https://developers.facebook.com/docs/android/getting-started

I tryed to get the haskkey from the provided command :

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

Here is the result : https://www.dropbox.com/s/s711ldu1y0aa6xo/screen.png

So I added it to my facebook develloper account as asked in the tutorial but, as it didn't work I tryed to get the hashkey from the following code.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Add code to print out the key hash
    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "com.facebook.samples.hellofacebook", 
                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) {

    }

I get the same result meaning my key is the right one... Do you guys know where could the problem be coming from ?

1

1 Answer 1

1

This Solution is with code, you have mentioned in your question:

You are getting the hash-key with debug key... Which may work if you haven't sign the package and running app in debug mode. What you need to do is :

0) Place that code in any of your activity.

1) Go to the manifest file and add to the application android:debuggable="true".

2) Now run your app and monitor the logcat.

3) You will get printed a new key which will be the matching key with x9SLcMXBlgly1f36PJuuc4a3YAc, The key you have got is now having a = sign in the last.

4) Register this key on facbook developer site

Alternate Trick

You can do one other thing Simply register this key to the facebook developers site x9SLcMXBlgly1f36PJuuc4a3YAc=

Just add = to the key which is being shown by the facebook app.

you are done!! Hope this will work.

1
  • I'll try this solution, I'll get back to you asap Jul 30, 2014 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.