I uploaded my fully working app on Google Play and when download it from there, facebook login doesn't work!! I properly configure my facebook app and works with eclipse environment. After searching, it can be done due to facebook key hashes. However, I obtained it like:
How to generate Key Hash for facebook SDK In Mac
Seems that a key hash for distribution must be also obtained... but how? Thank you.
Alternative 1:
Use this with the app signed with your release key. Not the one that is deployed from Eclipse.
Run this piece of code in the first Activity of your app:
try {
PackageInfo info = getPackageManager().getPackageInfo(
"YOUR_PACKAGE_NAME", PackageManager.GET_SIGNATURES);
for (Signature signature: info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.e("FACEBOOK APP SIGNATURE", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
This line: Log.e("FACEBOOK APP SIGNATURE", Base64.encodeToString(md.digest(), Base64.DEFAULT));
will log the Key Hash in DDMS.
Alternative 2:
- Download OpenSSl for Windows and extract the .zip to a simple location like: c:\openssl with all the contents of the zip extracted in this folder's root.
- Copy your signing key file to your JRE installation's bin folder. For example, in my case:
C:\Program Files\Java\jre7\bin
- While in the bin folder where you copied the signing key, Press SHIFT+ Right Click -> Open command window here.
- Run this command: keytool -exportcert -alias YOUR_ALIAS -keystore YOUR_SIGNING_KEY > c:\openssl\bin\debug.txt
- Enter your password for the signing key
- Now, navigate to the c:\openssl\bin folder and type in the following commands:
openssl sha1 -binary debug.txt > debug_sha.txt
And then,
openssl base64 -in debug_sha.txt > debug_base64.txt
Done! The debug_base64.txt contains your Key Hash. Copy this in your app console and you are all set.
In my experiece, both the methods have given me the correct Key Hash. However, in a few cases (rather random ones), the first alternative did not give the correct Key Hash while the second alternative has always worked. See which works for you.
While generating release Hash key, Note this
When generating the hash key for production you need to use openssl-0.9.8e_X64.zip
on windows, you cannot use openssl-0.9.8k_X64.zip
The versions produce different hash keys, for some reason 9.8k does not work correctly... 9.8e does.
OR
Use this below flow
This is how I solved this problem
Download your APK to your PC in java jdk\bin folder
in my case C:\Program Files\Java\jdk1.7.0_121\bin
go to java jdk\bin
folder and run cmd then
copy the following command in your cmd
keytool -list -printcert -jarfile yourapkname.apk
Copy the SHA1 value to your clip board
like this CD:A1:EA:A3:5C:5C:68:FB:FA:0A:6B:E5:5A:72:64:DD:26:8D:44:84
and open Hex To Base 64 to convert your SHA1 value to base64.
Try this solution, for me I was getting the same error, but working fine now after trying hours.
Login Error: There is an error in logging you into this application. Please try again later