0

I have setup Parse Facebook login just like in the documentations, with app key and everything else that was needed.

But no matter what I have tried I keep getting the following error:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/android/Facebook;

Caused by: java.lang.ClassNotFoundException: Didnt find class "com.facebook.android.Facebook" on path: DexPathList[[zip file "/data/app/com.example.myapp/base.apk"],nativeLibraryDirectories=[/data/appcom.example.myapp/lib/arm, /vendor/lib, /system/lib]]

Suppressed: java.lang.ClassNotFoundException: com.facebook.android.Facebook

Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

You have to HELP me, I have tried everything that I can find online, I really do! I'm losing my mind, What did I miss here?

Thanks!

42Geek
  • 332
  • 3
  • 7

3 Answers3

2

Those are the steps I followed to do the signup / login / linking of users with ParseUsers according to Parse documentation and some tips I found on the web:

  • First, I went to this website and created a new application.
  • I downloaded the Facebook SDK, I did the steps 4 and 5 and I added my package name and the default class name
  • I added the key hashes:

Development Key:

cd C:\Program Files\Java\jdk1.8.0_05\bin keytool -exportcert -alias androiddebugkey -keystore C:\Users\'YOUR NAME'.android\debug.keystore | C:\OpenSSL\bin\openssl sha1 -binary | C:\OpenSSL\bin\openssl base64

Release Key:

cd C:\Program Files\Java\jdk1.8.0_05\bin keytool -exportcert -alias 'NAME YOU GAVE AS ALIAS' -keystore | C:\OpenSSL\bin\openssl sha1 -binary | C:\OpenSSL\bin\openssl base64

  • In parse.com inside Settings and Authentication, I added in Facebook Application the APP ID that was created in Facebook.
  • According to this, I did all the steps until Using Login or Share (including this).
  • I went here and I added my development hash key.
  • In the Settings of the application that I created in Facebook, I checked that in the Key Hashes field, there were both Development and Release Keys.
  • I used the tutorial from the correct answer to make my application live.
  • I downloaded the latest SDK of Parse (1.9.1) from QuickStart because 1.8 it's not working.
  • I added the new .jar file of the SDK and the ParseFacebookUtilsV4-1.9.1 inside the libs folder of my project and syncronized the build.gradle file.
  • I added this line in strings.xml :
    <string name="facebook_app_id">1421******</string>

I added this in my AndroidManifest.xml inside Application tag:

<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" />

and this:

<meta-data android:name="com.facebook.sdk.ApplicationId"
    android:value="@string/facebook_app_id"/>

In build.gradle of the app I added these inside the android because of some errors with Diamond (I am sorry I can't remember the exact error):

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

and I changed the SDK version to be numbers because of some error of undefined variables:

minSdkVersion 14
targetSdkVersion 19

The related dependencies inside the same file:

compile fileTree(include: 'Parse-*.jar', dir: 'libs')
compile fileTree(include: 'ParseFacebookUtilsV4-*.jar', dir: 'libs')
compile 'com.facebook.android:facebook-android-sdk:4.0.0'

  • In the activity in which I want to do all those things with facebook I did the below things:

       Parse.initialize(this, "hoMaK", "wWV193mE");
    
        FacebookSdk.sdkInitialize(getApplicationContext());
    
        ParseFacebookUtils.initialize(getApplicationContext());
    
        final List<String> permissions = Arrays.asList("public_profile", "email");
    
        fb.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View view)
            {
                proDialog.show();
    
                ParseFacebookUtils.logInWithReadPermissionsInBackground(HomeActivity.this, permissions, new LogInCallback() {
                    @Override
                    public void done(final ParseUser user, ParseException err) {
                        if (user == null) {
                            Log.d("MyApp", "Uh oh. The user cancelled the Facebook login.");
    
                            Toast.makeText(getApplicationContext(), "Log-out from Facebook and try again please!", Toast.LENGTH_SHORT).show();
    
                            ParseUser.logOut();
    
                            proDialog.hide();
                        }
                        else if (user.isNew()) {
                            Log.d("MyApp", "User signed up and logged in through Facebook!");
    
                            if (!ParseFacebookUtils.isLinked(user)) {
                                ParseFacebookUtils.linkWithReadPermissionsInBackground(user, HomeActivity.this, permissions, new SaveCallback() {
                                    @Override
                                    public void done(ParseException ex) {
                                        if (ParseFacebookUtils.isLinked(user)) {
                                            Log.d("MyApp", "Woohoo, user logged in with Facebook!");
    
                                            proDialog.hide();
                                        }
                                    }
                                });
                            }
                            else{
                                Toast.makeText(getApplicationContext(), "You can change your personal data in Settings tab!", Toast.LENGTH_SHORT).show();
                            }
                        } else {
                            Log.d("MyApp", "User logged in through Facebook!");
    
                            if (!ParseFacebookUtils.isLinked(user)) {
                                ParseFacebookUtils.linkWithReadPermissionsInBackground(user, HomeActivity.this, permissions, new SaveCallback() {
                                    @Override
                                    public void done(ParseException ex) {
                                        if (ParseFacebookUtils.isLinked(user)) {
                                            Log.d("MyApp", "Woohoo, user logged in with Facebook!");
    
                                            proDialog.hide();
                                        }
                                    }
                                });
                            }
                            else{
                                proDialog.hide();
                            }
                        }
                    }
                });
            }
        });
    
  • With all the above steps, I can sign up or login using my Facebook account and I am getting a new line in _User object in Parse.com in which I can change the data any time I want to (I handle it as a normal sign-up user)

Community
  • 1
  • 1
Marialena
  • 817
  • 8
  • 31
0

Looking at the log output you've provided, it seems that your project configuration is wrong for the FacebookSDK and it can't be found. Check that you are including properly the SDK into the project and then try to rebuild.

Facebook documentation can help you: getting started

sparragol
  • 75
  • 7
0

I was having the same error, and what was missing was the following depedencies in app gradle.build file:

dependencies {

compile rootProject.ext.facebookSDK

}

Flávio Filho
  • 475
  • 4
  • 14