Katedral Pillon
Katedral Pillon

Reputation: 14864

Facebook release key hash for android not working

To generate my release key hash I do

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

Where of course I use my actual release key alias and actual release key path. Then I went on Facebook and added it under Key Hashes in Settings. But My release build is not working with it. My debug build worked fine with the debug key. Any ideas what's wrong?

Under what circumstances might my app be able to post photos to Facebook in debug mode but not in release mode? I am using the simple call

Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), photo, new Request.Callback() {
  @Override
  public void onCompleted(Response response) {
    Log.i(TAG, response.toString());
  }
});

Again, when I was using the debug key and build, it worked fine. Could the problem be Proguard? I am using the following lines

-keep class com.facebook.** { *; }
-keepattributes Signature

Upvotes: 0

Views: 953

Answers (1)

Jitender Dev
Jitender Dev

Reputation: 6925

To make sure your keyhash is correct you can verify using below code

 // Add code to print out the key hash
    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "yourpackagename", 
                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) {

    }

imports

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;

Upvotes: 2

Related Questions