Facebook SSO example does not work - "An error has occurred. Please try again later."

I am trying to integrate facebook into my application and therefore follow the training course: Facebook Android , but I can not get the first example (Single Sign-On) to work. When my application loads, I get a facebook dialog, but it just says: "An error has occurred. Please try again later." with the ok button in facebook style below and in the logarithm there is nothing: App showing Facebook error

I followed the steps in the tutorial, but I assume that something is wrong with the APP ID or hashkey generated by keytool. Here are the steps I followed:

  • clone fb git.
  • create an fbSDK project.
  • create your own fb project and link fbSDK as a library.
  • Then I made keytool cmd with openssl and entered the password “android”, as suggested by others, in stackoverflow.
  • I went to developer.facebook.com and created a new application.
  • In "Change settings-> Mobile devices and devices" I put my hash in the provided field.
  • In "Edit Settings-> Mobile Devices and Devices" I selected "Native Application" as "Application Type"
  • In the application, I copy and paste the SSO example code.
  • I changed "YOUR_APP_ID" in the constructor of Facebook () to the APP identifier specified on developers.facebokk.com for my new application.
  • I launched the application on my phone.

I don’t know why there is nothing in logcat, but when I install it, the console always, without fail, says: ActivityManager: Warning: Activity not started, its current task has been brought to the front

And I can not find the logcat link for my application or the error I received from facebook sdk which was: Facebook-ProxyAuth(4828): Failed to read calling package signature.

I have been doing this for several hours, and any help would be greatly appreciated. I can’t believe that the facebook SDK and help are so sketchy for Android, facebook should be ashamed of itself.

Thanks,

Infinitifizz

+6
android facebook facebook-android-sdk
source share
5 answers

You need to call .request () from a separate thread. If you do this in the user interface thread, facebook authorization will not be completed before your code is executed. So call the new thread in the "onComplete" facebook authorization. At the moment, you will have a valid access token. Good luck

(that’s why the api says “don’t call it from the user interface thread!”.)

+2
source share

Actually, I ran into the same problem and solved. So, in the hash key gene, use the following steps:

  • open cmd and navigate to your Android SDK path.
  • enter this command: keytool -exportcert -alias androiddebugkey -keystore [your path to the SDK | eg c: \ users \ user] .android \ debug.keystore | openssl sha1 -binary | openssl base64
  • after that it will skip the password, enter "android"
  • copy the result into the settings of your facebook application and save the settings.
  • in your android application use facebook app id (not android hash key).
+2
source share

I had this problem simply because I made calls in facebook api before correctly initializing the facebook object with the correct key. Just make sure you use the correct key and you are properly initializing the Facebook object.

In addition, I also stumbled several times trying to make facebook api calls with a different Android app key. Keep in mind that in the facebook tutorial you have to create your key using compiled apk. This key hash will be different if you intend to run your code from the IDE (I use Eclipse). When you launch the application directly from eclipse, the facebook key will be different because when you launch your application from eclipse it uses the default key to create your application.

Because of this, I usually have two keys on the facebook developer portal. One key created using apk compiled with the release key used for the Android market, and another key that was created from running the application code directly from eclipse.

+1
source share

Any reason why you selected your own app in step 7? I left it on the default HTML5 / mobile website and got a sample to work with.

0
source share

The best way to know your hash correctly is with a piece of code.

 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { PackageInfo info = getPackageManager().getPackageInfo( "com.facebook.samples.loginhowto", PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } ... 

Replace com.facebook.samples.loginhowto with your own package name.

0
source share

All Articles