Okey, I've done all the business, followed all the steps, but still can't get it to work. The simple Example app that comes with the Facebook SDK, is working on the emulator and on devices with android 1.5. So my guess is the single login thing.
If I'm right then I should generate a key hash and I've been told that the right debug keystore is placed under
C:\Users\xxx.android\debug.keystore
so I followed the tutorial.
Downloaded OpenSSL from google.code and in the terminal I write something like:
"C:\Program Files\Java\jdk1.6.0_22\bin\keytool.exe" -exportcert -alias androiddebugkey -keystore "C:\Users\JoeZ.android\debug.keystore"|"C:\Users\xxx\Downloads\openssl-0.9.8k_X64\bin\openssl.exe" sha1 -binary|"C:\Users\xxx\Downloads\openssl-0.9.8k_X64\bin\openssl.exe" base64
and I get a nice key which I inserted into the Android Key Hash box in facebook, I've tried both with or without the = sign after the output but nothing seems to work.
I just get invalid_key when I try to sign into the Example application. I even tried a signed application but it did not work. And if I'm not mistaken the only thing to write in the Example application is my APP_ID, right?
I'm having the exact same problem with my own application that I'm developing. So please can anybody help me?
To use the Facebook SDK in an Android Studio project, add the SDK as a build dependency and import the SDK. Go to Android Studio | New Project | Minimum SDK. Select API 15: Android 4.0. 3 (IceCreamSandwich) or higher and create your new project.
This documentation describes how to integrate your Android app with Facebook to build engaging social apps by using the Facebook SDK for Android. To learn more about using Facebook development tools, see App Development.
Can I run mobile app ads without using the SDK? Yes, we allow anyone to run mobile app install ads from our Ads Create Tool simply by dropping the link to their Apple App Store or Google Play URL. For mobile app engagement ads, you will need to register your app, but can also run ads without the SDK.
If the keytool command doesn't work for you, I found a way around that stuff: you can just reverse engineer which key to put as Key Hash in the Facebook Developer section. Within your Activity just print out the Key Hash by doing:
try {
PackageInfo info = getPackageManager().getPackageInfo("[your package name, e.g. com.yourcompany.yourapp]", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("Hash Key:", Base64.encode(md.digest()));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
This worked for me. The MessageDigest class is included in the JDK. The Base64 class not. You can use this one for example.
I had a similar problem. For me, it was resolved when I uninstalled the latest update of the Facebook app and now only have the native Facebook app v1.2. (Means, when I go into the market and search for Facebook, the "Facebook for Android" would be displayed as 'not installed' on my device).
On my Nexus One (Android 2.2.1), when I had the latest Facebook app installed, there was not 'uninstall app' buton, only a 'Uninstall latest updates', which is what I did. In fact, I can't even uninstall the entire Facebook (now v1.2) app for whatever reason, the uninstall button is disabled/greyed out. But in this status, the samples seem to work.
At least, I could get the simple and stream app to work this way.
Edit / Solution:
Ok, I got it working now. I found that I copy/pasted the wrong key hash, due to some weird behaviour of keytool under windows and a wrong command syntax in the ReadMe file of the Facebook SDK.
The parameter to be used should be "keytool -export ...
" and not "keytool -exportcert ...
"; if you do use the second/wrong parameter, keytool would still print out a hash key (withouth asking for any key password though), but the hash is wrong.
Now I got SSO working as well.
This is my call on windows:
keytool -export -alias androiddebugkey -keystore "C:\Documents and Settings\myuser\.android\debug.keystore" | openssl sha1 -binary | openssl enc -a -e
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With