hello all in one of my app I need to get data of fb... I am doing that..
I have created app ID it log in successfully but after log out i Log In then it gives me
What is wrong I am doing? Please suggest I am using Facebook sdk... I have installed Facebook in my phone... this running good in emulator that does not have inbuilt Facebook application installed
this is my code
if (FB_APP_ID == null) {
Builder alertBuilder = new Builder(this);
alertBuilder.setTitle("Warning");
alertBuilder.setMessage("A Facebook Applicaton ID must be " +
"specified before running this example: see App.java");
alertBuilder.create().show();
}
// Initialize the dispatcher
Dispatcher dispatcher = new Dispatcher(this);
dispatcher.addHandler("login", LoginHandler.class);
dispatcher.addHandler("stream", StreamHandler.class);
dispatcher.addHandler("logout", LogoutHandler.class);
// If a session already exists, render the stream page
// immediately. Otherwise, render the login page.
Session session = Session.restore(this);
if (session != null) {
dispatcher.runHandler("stream");
} else {
dispatcher.runHandler("login");
}
I got the same problem.I was sure that it was due to very small fault and yes it was!!!! I found the solution.
When generating debug hash key in my computer, I entered the password of my system.But the password should be the following -
Enter keystore password: "android"
This was the only problem in my case.
----- For generating Debug key hash, use this command -
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
Enter keystore password: 'android'
----- To Generate Release key hash, use this command -
keytool -exportcert -alias "alias of keystore" -keystore "Your path to the keystore when signing app" | openssl sha1 -binary | openssl base64
Provide your keystore password after executing this command.
I had the same problem when I was debugging my app. I've rewrited the hash that you have crossed out in the attached image (the one that Facebook says is invalid) and added it in Facebook's developers console to key hashes. Just be careful on typos.
This solution is more like easy work-around than a proper solution.
You must create two key hashes one for Debug and one for Release.
For Debug key hash:
On OS X, run:
On Windows, run:
Debug key hashes source
For Release key hash:
On OS X, run: ( Replace what between <> with your values )
On Windows, use: ( Replace what between <> with your values )
Release key hashes source
The generate hash key is wrong. You may get the hash key using two steps. One is through command prompt. Another one is through coding. Hash key through command prompt working on first time only. I don't know the reason. I have also got the same problem. So i tried it through programatically.
Follow this steps:
Paste the following code in
oncreate()
.Modify "com.example.packagename" with your package name in the above coding without fail(You may found your package name in Android Manifest file).
Run your application. Go to the activity where you pasted the above code. In the logcat search for "KeyHash". You may found a key hash. Copy the key hash and go to Facebook application dashboard page. Go to settings and enter the details like in the bellow image.
Once you finished the above step. Relaunch the app again you may now log into the facebook. For more details about key hash check the link
If you add a wrong information in the settings page means it will give some error. so use the correct information there. And also if public(other than you) need to use your application means you need to enable the permission
(change "yes" in the "Status & Review" next to setting)
.I experienced the same problem. I made a short research on the possible reasons for this strange behavior and I found the following:
During the first execution of a new Facebook app, it will allow connection/login even if you don't specify any key hashes.
For me, the tutorial which Facebook provided didn't generate the correct key hash, because it was giving the wrong configuration. When executing:
make sure you check all properties - the
HOMEPATH
, the existence of the keystore, etc. Maybe you also have to provide password.What generated the proper configuration was the solution suggested by @Mahendran.
Also, if you see the error originally posted (http://i.stack.imgur.com/58q3v.png), most probably the key hash you see on the screen is your real one. If nothing else works, try inputting it in Facebook.
I got all those results with: Windows 7 64-bit edition, Android Studio 1.2.2, JDK 7.
According Facebook Login for Android, you must provide the Key Hash value. In order to obtain it, you will need the key used to sign your application.