How to create Android Facebook Key Hash?
Here is what you need to do -
Download openSSl from Code
Extract it. create a folder- OpenSSL in C:/ and copy the extracted code here.
detect debug.keystore file path. If u didn't find, then do a search in C:/ and use the Path in the command in next step.
detect your keytool.exe path and go to that dir/ in command prompt and run this command in 1 line-
$ keytool -exportcert -alias androiddebugkey -keystore "C:\Documents and Settings\Administrator.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary |"C:\OpenSSL\bin\openssl" base64
it will ask for password, put android
that's all. u will get a key-hash
Facebook Android Generate Key Hash
Delete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERHOME%/.android on Windows.
The Eclipse plugin should then generate a new certificate when you next try to build a debug package.
Let me know if that works.
Facebook key hash does not match any stored key hashes
After hours of trying I've finally found a solution.
- Delete any app on the website of Facebook (developers.facebook.com)
- Delete the file debug.keystore under
C:\Users\yourUserName\.android
- Generate a new key (by running your app again)
- Create a new app on developers.facebook.com and add the new hash key
- Re-run your app
- Succes!
Invalid Key Hash using Android Facebook sdk
Look, you generate KEY HASH
with debug key ~/.android/debug.keystore
but you need to set here your key which you using for publish on Google Play ~/.android/release.keystore
keytool -exportcert -alias androiddebugkey -keystore ~/.android/folder_with_your_release_key/release.keystore | openssl sha1 -binary | openssl base64
and generated KEY HASH
add to facebook developer console
Step by step:
Go to https://developers.facebook.com and open Settings->Basic->Android->Key Hashes and copy paste here you KEY HASH that you generated with keytool, BUT ONLY using you release key, NOT debug (see command above)
Questions about Development and Release Key Hashes for Facebook SDK for Android
Q: What do those Key Hashes do?
- They identify your keystore and application uniquely. it is a unique
fingerprint for your application:
Signing Your Applications
- Android requires that all apps be digitally signed with a certificate
before they can be installed. Android uses this certificate to
identify the author of an app, and the certificate does not need to
be signed by a certificate authority. Android apps often use
self-signed certificates. The app developer holds the certificate's
private key.
Signing Overview
- You can sign an app in debug or release mode. You sign your app in
debug mode during development and in release mode when you are ready
to distribute your app. The Android SDK generates a certificate to
sign apps in debug mode. To sign apps in release mode, you need to
generate your own certificate. For your further reference you can
look at what keyhashes are at
http://developer.android.com/tools/publishing/app-signing.html
https://developers.facebook.com/docs/facebook-login/android
Q: Why is there a need to create different key hashes for both Release and Development?
As you know android uses different Keystores for both development and release, since the two keystores are different in every aspect, they both have different fingerprints and SHA-1 hashes hence they are treated entirely different.
Q: If I haven't published my app to the PlayStore yet. Can I use the Release Key instead of using the Development key?
Yes you can use the release key for APK generation purposes only however if you are in debug mode this key wont work at all.
Q: If I my app is live in PlayStore, can I keep using the Development key?
Yes you can keep using development key but you cannot use the debug key.
Q:What should I put into YOUR_RELEASE_KEY_ALIAS and YOUR_RELEASE_KEY_PATH? Can anyone provide samples please?
attached is image if you are concerned about facebook keys
Q:Why is that when we develop for iOS, those key hashes were not required?
That is due to platform requirement. It isn't necessary that if one platform requires one thing the other platform will also.
Single Sign On
Single sign-on is roughly an extension of (and replacement for) services like Facebook Connect, connecting you to third-party social apps and services. If you're already logged on to Facebook on your mobile phone, you'll be able to sign in to other apps using your Facebook credentials.
Here is the code to generate fb fingerprint.
public void generateFbFingerPrint() {
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.group3amd.gc.activity",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String sign = Base64
.encodeToString(md.digest(), Base64.DEFAULT);
Log.e("KEYHASH:", sign);
Toast.makeText(getApplicationContext(), sign, Toast.LENGTH_LONG)
.show();
}
} catch (NameNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
Facebook android app error : Invalid key hash
As I understand you've got your key hash, but still I'll put here the code for getting it in the console.
PackageInfo info;
try {
info = getPackageManager().getPackageInfo("com.your.project.package", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md;
md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String something = new String(Base64.encode(md.digest(), 0));
//String something = new String(Base64.encodeBytes(md.digest()));
Log.e("hash key", something);
}
} catch (PackageManager.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());
}
Where "com.your.project.package"
is the package of your project =)
Next thing, dont delete previous key hash, they don't conflict I think. For example I have 2 keyhashes in my facebook app.
And the latest thing, and I think this is the problem. Go to the Status&Review of your app at the developers.facebook. And switch your application to public.
Key hash for Facebook Android SDK
- Download and install OpenSSL from http://slproweb.com/products/Win32OpenSSL.html based on windows 32 or 64 bit.(Note: Download and install first visual C++ 208 redisributable from that site also )
- Put the bin directory of installed OpenSSL in windows path.
- Open the command prompt and go to C:\Users{User_Name}.android
- now put this command on cmd "keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64".(refer https://developers.facebook.com/docs/android/getting-started#samples)
- Now enter password "facebook" without double quote.
- Now a hash key will be generated
- Finally go to the Facebook Developer site. Make sure you are logged into Facebook and, using the dropdown menu in the top-right, go to your 'Developer Settings':
- Once you're in your developer settings, select 'Sample App' from the navigation on the left, and add and save your key hash into your profile:
Related Topics
How to Draw a Filled Triangle in Android Canvas
How to Check Wifi or 3G Network Is Available on Android Device
How to Kill Currently Running Task in Android
Ksoap2 Org.Xmlpull.V1.Xmlpullparserexception Expected Start_Tag Error
Dx Bad Class File Magic (Cafebabe) or Version (0033.0000) with Adk14
Android Microsoft Office Library (.Doc, .Docx, .Xls, .Ppt, etc.)
How to Serialize Object to JSON
Android:Change App Label Programmatically
Java - Ignore Expired Ssl Certificate
Dynamically Get Drawables by Id
Is There an Easier Way to Parse Xml in Java
Android Fragmentmanager Backstackrecord.Run Throwing Nullpointerexception
How to Set Seekbar Min and Max Value