I'm trying to integrate facebook into my app and so have followed the tutorial at: Facebook Android but I can't get the first example (Single Sign-On) to work. When my app loads up I get the facebook dialog but it just says "An error occurred. Please try again later." with a facebook-style "Ok" button at the bottom and there is nothing in logcat:
I followed the steps in the tutorial but I'm guessing there is something wrong with the APP ID or the hashkey generated by keytool. Here are the steps I followed:
I don't know why there is nothing in logcat but when I install it, the Console always, without fail, says the:ActivityManager: Warning: Activity not started, its current task has been brought to the front
And I can't find any logcat reference to my app or the error I was getting from the facebook sdk which was: Facebook-ProxyAuth(4828): Failed to read calling package's signature.
I have been at this for a few hours now and any help would be greatly appreciated. I can't believe the facebook SDK and help is so sketchy for Android, facebook should be ashamed of themselves.
Thanks,
InfinitiFizz
You have to call .request() from a separate thread. If you do it on the UI thread the facebook authorize doesn't complete before your code executes. So call the new thread in the "onComplete" of facebook authorization. You'll have a valid access token at this point. Good luck!
(this is why the api says "don't call this from the UI thread!".)
In fact I have encountered the same problem exactly and it solved. So, in the hash key generation use the following steps:
I had this problem simply because I was making calls to the facebook api before I properly initialized the facebook object with the correct key. Just make sure you're using the right key and you're initializing the Facebook object properly.
Also, I've also been tripped up a few times by attempting to make facebook api calls with a different android application key. Keep in mind that the facebook tutorial instructs you to create your key with a compiled apk. This key hash will be different if you're going to run your code from the IDE (i'm using Eclipse). When you run your app directly from eclipse the facebook key will be different because when running your app from eclipse it's using a default release key to build your app.
Because of this I usually have two keys in the facebook developer portal. One key that was created with an apk compiled with the release-key used for the Android market and another key that was created from running the app code directly from eclipse.
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