title: Facebook Android SDK & java.lang.NullPointerException
body: <p>I am having trouble opening an active facebook session in my android app as per the tutorial posted at <a href="https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/" rel="noreferrer">https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/</a></p>
  
  <p>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! (<em>I bet the error is with some setup on my side, but I am unable to spot it</em>)</p>
  
  <p>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)</p>
  
  <hr>
  
  <p><strong>EDIT :</strong> 
  The following warning message is logged first and followed by the error message in the subsequent screen shot</p>
  
  <blockquote>
    <p>09-03 19:26:22.726: W/Bundle(17458): Key
    <strong>com.facebook.platform.protocol.PROTOCOL_VERSION expected String but
    value was a java.lang.Integer. The default value  was returned.</strong> 
    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)</p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/6Xrnv.png" alt="enter image description here"></p>
  
  <hr>
  
  <blockquote>
    <p>09-02 22:55:04.110: E/AndroidRuntime(13287): FATAL EXCEPTION: main
    09-02 22:55:04.110: E/AndroidRuntime(13287):
    java.lang.RuntimeException: <strong>Unable to resume activity</strong>
    {com.good.amrfbintegration/<strong>com.facebook.LoginActivity</strong>}:
    <strong>java.lang.NullPointerException</strong> 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)</p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/CZBPw.png" alt="enter image description here"></p>
  
  <p>Here is what I have done so far</p>
  
  <p>Updated the App on Facebook with the following information (I have used the hashkey generated using my machine's debug keystore)</p>
  
  <p><img src="https://i.stack.imgur.com/We43W.png" alt="enter image description here"></p>
  
  <p>Here are the relevant info from my manifest file (@string/app_id is the App Id from facebook dev portal)</p>
  
  <p><img src="https://i.stack.imgur.com/qj7yR.png" alt="enter image description here"></p>
  
  <p>I added a reference to the Facebook SDK to my project in this way</p>
  
  <p><img src="https://i.stack.imgur.com/JVsSZ.png" alt="enter image description here"></p>
  
  <p>Here is the code in my OnCreate method of the main activity</p>
  
  <pre><code>@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);
      }
  </code></pre>
  
  <p>On executing the Session.openActiveSession, logcat display the error shown in my first screenshot.</p>
  
  <p>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</p>
  
  <p><img src="https://i.stack.imgur.com/FacYu.png" alt="enter image description here"></p>
  
  <p>Any assistance would be greatly appreciated!</p>