Error compile in “Use Facebook Login example”

2019-03-11 14:21发布

问题:

I'm trying to create the Login Application in this tutorial:

I'm getting this error in my logcat:

11-22 15:57:53.863: E/AndroidRuntime(816): com.facebook.FacebookException: Cannot use SessionLoginBehavior SSO_WITH_FALLBACK when com.facebook.LoginActivity is not declared as an activity in AndroidManifest.xml

Anyone know why?

回答1:

May you forgot to define Activity in your AndroidManifest.xml

<activity
    android:name="com.facebook.LoginActivity"
    android:label="@string/title_facebook_login" >
</activity>


回答2:

I had the same problem and it was because I forgot to add the com.facebook.LoginActivity activity to AndroidManifest.xml.

Also check that you followed the steps on the "Create a new Android Project with Facebook Login" section on https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/ , specially those regarding adding the app_id string to res/values/strings.xml, the INTERNET permission, the com.facebook.sdk.ApplicationId Meta Data, and finally the mentioned LoginActivity.



回答3:

While the original question is related to SDK 3.0 I think it's worth mentioning that in SDK v4.0.+ the activity that needs to be declared in the AndroidManifest.xml is com.facebook.FacebookActivity eg:

<activity android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:theme="@android:style/Theme.Translucent.NoTitleBar"
    android:label="@string/app_name" />


回答4:

In this link

<activity
    android:name="com.facebook.LoginActivity"
    android:label="title_facebook_login" >
</activity>

is not mentioned.

Add this in AndroidMainfest.xml and problem solved.



回答5:

https://developers.facebook.com/docs/reference/android/3.0/class/LoginActivity/

<activity
    android:name="com.facebook.LoginActivity"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Translucent.NoTitleBar">
</activity>