NullPointerException when logging in using the Facebook SDK and ParseFacebookUtils

We are using the Parse SDK and trying to log in with the Facebook feature. But we could not understand it. We get a NullPointerException. What is wrong with our implementation?

Our versions of the SDK that we used: Parse SDK 1.10.3 , Facebook SDK 4.7.0 , ParseFacebookUtilsV4-1.10.3

Stacktrace

11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at com.facebook.login.LoginClient.getLogger(LoginClient.java:363) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at com.facebook.login.LoginClient.logAuthorizationMethodComplete(LoginClient.java:413) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at com.facebook.login.LoginClient.tryNextHandler(LoginClient.java:196) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at com.facebook.login.GetTokenLoginMethodHandler.getTokenCompleted(GetTokenLoginMethodHandler.java:119) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at com.facebook.login.GetTokenLoginMethodHandler$1.completed(GetTokenLoginMethodHandler.java:74) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at com.facebook.internal.PlatformServiceClient.callback(PlatformServiceClient.java:157) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at com.facebook.internal.PlatformServiceClient.handleMessage(PlatformServiceClient.java:141) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at com.facebook.internal.PlatformServiceClient$1.handleMessage(PlatformServiceClient.java:62) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at android.os.Looper.loop(Looper.java:145) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5834) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388) 11-08 15:27:34.507 8983-8983/com.taurus.trolley E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183) 

We have added this code below in the manifest.

AndroidManifest.xml:

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

We have added this code below to the Application # onCreate () method.

Application # OnCreate ():

  // Facebook SDK initializing FacebookSdk.sdkInitialize(getApplicationContext()); // Enable Local Datastore. Parse.enableLocalDatastore(this); Parse.initialize(this, PARSE_APP_ID, PARSE_CLIENT_KEY); ParseFacebookUtils.initialize(this); 

Code that provides the login function:

  List<String> permissions = Arrays.asList("public_profile", "email"); ParseFacebookUtils.logInWithReadPermissionsInBackground(this, permissions, new LogInCallback() { @Override public void done(ParseUser user, ParseException e) { if (user == null) { Log.d(TAG, "Uh oh. The user cancelled the Facebook login."); } else if (user.isNew()) { Log.d(TAG, "User signed up and logged in through Facebook!"); } else { Log.d(TAG, "User logged in through Facebook!"); } } }); 
+5
source share
1 answer

I had the same problem. After waiting a while, he works flawlessly. So, I think that FB needs to do something when you log in.

0
source

Source: https://habr.com/ru/post/1235471/


All Articles