Session Provided to a request in unopened state - android

Facebook friend picker sample in the Facebook SDK 3.0 shows error dialoge box.
the message box says:
'com.facebook.Facebook Exception : Session Provided to a request in unopened state.'

I had this exact error, if you are running this from Eclipse then there is a good chance there is a more detailed error in the log cat. For me I found the real error was that my Android hashkey did not match up with the hashkey I had provided to Facebook.
Double check that the hashkey you are using is correct. See this Answer for setting up your hashkey
Key hash for Android-Facebook app
Further, using the Keytool did not help me for my HashKey, instead I followed the advice on this guide:
https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/
In step 4, see Troubleshooting, and modify the code to output your HashKey and use that one instead. The hashkey I had generated from Keytool was much different than this one. After that recompile everything, it should work fine.

Related

Android KeyHash Valid when Debug, Invalid when I install the App from APK

I got KeyHash using this.
Of course, I copied this (KeyHash, package name and main activity class) to facebook settings according this.
And when I debug my app it looks fine (I can login and logout how many times I want), but when I create APK and run the app I received common error "invalid key hash the key hash does not match any stored key hash..."
What do I need to except getting right KeyHash and adding it into your Facebook App ID's Android settings?
You have to call
FacebookSdk.sdkInitialize(getApplicationContext());
before calling
FacebookSdk.getApplicationSignature(getApplicationContext());
to avoid getting NULL
This worked fine for me.

Facebook share dialog android return error

I want to share a simple link from my android app.
I followed the getting started guide from Facebook and all seem okay in my app since I can open the share dialog.
I imported FacebookSDK project and linked library
I set my appproperly (package/class name and dev hash keys)
My manifest has right permissions and meta-data
Additional infos :
I use a real device for debug
I run a test app as admin
I'm running a simple share code sample from an activity
I had troubles to generate hash keys but that post helped me. I got an error saying XXX key (different from the one I generated) doesn't match.
Then I tried the method explained here (at the end) to log another key.
Since now, I just get a toast saying "Something went wrong. Please try again."
What am I doing wrong ?
So I solved my problem thanks to another post. The problem is I was trying to generate a key outside my main (first) class.

Hashkey mismatch android facebook app

Downloaded recent facebook android sdk 3.7 and i tried to run sample apps in the sdk. When I tried helloFacebookSample app i got hashkey problem. I searched through web and got my hashkey correct i.e DSygOIIJUkYyHy/duT1e72ZHl5U=.
My app is showing "hashkey not stored" error. When I logged my sample app hashkey I found strange thing happening.
I am using this code:
Toast.makeText(getApplicationContext(),Base64.encodeToString(md.digest(), Base64.DEFAULT), Toast.LENGTH_LONG).show();
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
Toast.makeText(getApplicationContext(),Base64.encodeToString(md.digest(), Base64.DEFAULT), Toast.LENGTH_LONG).show();
Same piece of code is showing different hashkeys
DSygOIIJUkYyHy/duT1e72ZHl5U=
2jmj7l5rSw0yVb/vlWAYkK/YBwk=
and when I try to post status it shows a different hashkey.
DSygOIIJUkYyHy_duT1e72ZHl5U=
I have stored all three hashkeys in my sample app, and it is still showing me this error.
This problem usually comes when hashkey generated by your app doesnt match with the one which you have put in facebook developers site. Try to generate the hashkey programmatically and put it in developers site. Hope this solution helps
The same problem occurred to me , i had no idea what gone wrong ,then i realized that that key store that i used to generate the key hash was a different one ,if you have signed your app you will get a .jks key store file ,you have to specify that path of the file in the code generating the key hash like
keytool -list -v -keystore yourkeystore_path/yourkeystore.jks -alias your_aliase_name
the names of the keystore file and aliases name should be same as the one when you signed your app then your get the correct code for sure.
then there also a work around just write down the code displaying in the error and put it in the keyhash field simple as that...
hope it helps

Facebook ShareDialog com.facebook.FacebookException

I am trying to share to facebook from my app I followed this tutorial bascially copy and paste
https://developers.facebook.com/docs/android/share-dialog/#setup
but when I run the example the error I get back is
Error: com.facebook.FacebookException
That is it with no more details. I have triple checked by app hash and it is correct
I was using openForPublish instead of openForRead which is counter intuitive but still works. The Facebook Share Dialog doesn't need publish permissions to work

Android: Error when login Facebook using new Facebook SDK v3.0.2.b sample

when I using new Facebook SDK v3.0.2.b sample HelloFacebookSample, I login to Facebook but I get error:
HelloFBSample is misconfigured for Facebook login.
But I have already generate Hash key and add it to Sample App Setting on Facebook Developer site.
Is anybody get the same defect?
Or is it a bug of new SDK?
Sometimes the Key Hash generated using the method given by the Facebook Doc does not always work as advertised. I have faced this problem and so have a few others.
There are a couple of things you can do to sort it out.
First method
Follow the tutorial on this site: http://www.helloandroid.com/tutorials/using-facebook-sdk-android-development-part-1
This is a little time consuming (about 5 odd minutes I expect) but worked when I tried it.
Second Method (And I personally like this one)
Find the Util.java in the Facebook SDK and open it.
Among the first few lines of code, you should see this piece: private static boolean ENABLE_LOG = false;.
Change the false to true and run your application with your logcat (DDMD) open.
You should see an error that looks something like this:
Login failed: invalid_key:Android key mismatch. Your key
"**real*key***" does not match the allowed keys specified in
your application settings.
If this is for a testing APK, using the debug.keystore, this will be enough. However, if this is for an app signed with your release key, then follow the steps till Step No. 3 but instead of pushing the app from eclipse, create a signed APK and install that on your device. Don't forget to keep it connected with DDMS running.
This part here: "**real*key***" is your actual key.

Categories

Resources