Q: Parse and Facebook integration (no class def found error) I am developing an Android app that uses Parse BaaS and I want to enable users to login using their facebook account. I am using Android Studio. I imported facebook sdk and Parse and ParseFacebookUtils jar files.
I have the following activity code
private void initUI() {
    this.loginButton = (Button) findViewById(R.id.main_login_button);
    this.loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            loginWithFacebook();
        }
    });
}

private void loginWithFacebook() {
    ParseFacebookUtils.logIn(this, REQUEST_LOGIN, new LogInCallback() {
        @Override
        public void done(ParseUser parseUser, ParseException e) {
            logToDisplay("User logged in " + parseUser.getUsername());

        }
    });
}

The loginWithFacebook method is called. Unfortunately, it throws the following exception:
java.lang.NoClassDefFoundError: com.facebook.Session$Builder

What am I doing wrong?
Thanks in advance ;)

A: With Parse Android 1.9, we have to include ParseFacebookUtils4.jar
Also the example given in the documentation is not valid after doing a research for 12 hours. Here is the working solution i have for Parse 1.9 and Facebook 4.0 SDK
 Button b = (Button)findViewById(R.id.login_button);
    ParseFacebookUtils.initialize(this);
    //showHashKey(this);
    b.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ParseFacebookUtils.logInWithReadPermissionsInBackground(YOUR_ACTIVITY.this, YOUR_PERMISION_COLLECTION, new LogInCallback() {
                @Override
                public void done(ParseUser user, ParseException err) {
                    if (user == null) {
                        Log.d("MyApp", "Uh oh. The user cancelled the Facebook login.");
                    } else if (user.isNew()) {
                        Log.d("MyApp", "User signed up and logged in through Facebook!");
                    } else {
                        Log.d("MyApp", "User logged in through Facebook!");
                    }
                }
            });
        }
    });

ParseFacebookUtils.logIn is deprecated in ParseFacebookUtils4. Also there is another deprecated function ParseFacebookUtils.finishAuthentication on onActivityResult. It should be now like below
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    ParseFacebookUtils.onActivityResult(requestCode, resultCode, data);
}


A: I found out another difference when in ported Parse Android SDK 1.9 and Facebook SDK 4.
In your Manifest file replace
<activity android:name="com.facebook.LoginActivity"
          android:screenOrientation="portrait"/>

with this:
<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" />

Maybe it helps someone.
