I am having trouble opening an active facebook session in my android app as per the tutorial posted at https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/
I have been struggling with this for quite some time now without any luck! I will be glad if one of you would point me in the right direction! (I bet the error is with some setup on my side, but I am unable to spot it)
Here is the error I am seeing after calling Session.openActiveSession(this, true, new Session.StatusCallback() in the onCreate of my activity (I am pretty much following the steps given in facevook developer tutorials)
EDIT : The following warning message is logged first and followed by the error message in the subsequent screen shot
09-03 19:26:22.726: W/Bundle(17458): Key com.facebook.platform.protocol.PROTOCOL_VERSION expected String but value was a java.lang.Integer. The default value was returned. 09-03 19:26:22.736: W/Bundle(17458): Attempt to cast generated internal exception: 09-03 19:26:22.736: W/Bundle(17458): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String 09-03 19:26:22.736: W/Bundle(17458): at android.os.Bundle.getString(Bundle.java:1061) 09-03 19:26:22.736: W/Bundle(17458): at android.content.Intent.getStringExtra(Intent.java:4466) 09-03 19:26:22.736: W/Bundle(17458): at com.facebook.AuthorizationClient$KatanaLoginDialogAuthHandler.tryAuthorize(AuthorizationClient.java:821) 09-03 19:26:22.736: W/Bundle(17458): at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:272)
09-02 22:55:04.110: E/AndroidRuntime(13287): FATAL EXCEPTION: main 09-02 22:55:04.110: E/AndroidRuntime(13287): java.lang.RuntimeException: Unable to resume activity {com.good.amrfbintegration/com.facebook.LoginActivity}: java.lang.NullPointerException 09-02 22:55:04.110: E/AndroidRuntime(13287): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3036) 09-02 22:55:04.110: E/AndroidRuntime(13287): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3077) 09-02 22:55:04.110: E/AndroidRuntime(13287): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2373)
Here is what I have done so far
Updated the App on Facebook with the following information (I have used the hashkey generated using my machine's debug keystore)
Here are the relevant info from my manifest file (@string/app_id is the App Id from facebook dev portal)
I added a reference to the Facebook SDK to my project in this way
Here is the code in my OnCreate method of the main activity
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activity = this;
Session.openActiveSession(this, true, new Session.StatusCallback()
{
@Override
public void call(Session session, SessionState state, Exception exception)
{
if (session.isOpened())
{
Toast.makeText(activity, "Connected to Fb", Toast.LENGTH_SHORT).show();
}
}});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
On executing the Session.openActiveSession, logcat display the error shown in my first screenshot.
The Session.StatusCallback()'s call method gets executed once (while session has a state 'opening') but the app crashes the subsequent time. here is what I see before the App crashes
Any assistance would be greatly appreciated!
This problem because of Facebook SDK, please download and use Facebook SDK 3.5.2 from this URL:-https://developers.facebook.com/docs/android/