Jump to content

Implementing Facebook into your Android app: "invalid key" with keytool

0
  Programmer XR's Photo
Posted May 23 2011 01:07 PM

I recently had an annoying error. I wanted to implement some "Post to Facebook" functionality to my application and i got an error saying that my key vas invalid...

To implement this I just followed the official implementation of the SDK and after a quick search it seems that its is a problem that more developers run into.

I found the answer to my problem on StackOverflow. Mr. Omsn just makes the key that the Facebook API wants from within your application.

Here is a quick code snippet:

try {
   PackageInfo info = getPackageManager().getPackageInfo("**YOURPACKAGENAME**", PackageManager.GET_SIGNATURES);
   for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.i("PXR", Base64.encodeBytes(md.digest()));
   }
}
catch (NameNotFoundException e) {}
catch (NoSuchAlgorithmException e) {}


For more info and a source project check out this android tutorial blog

Tags:
0 Subscribe


0 Replies