简体   繁体   English

带有解析Facebook登录名的Android NullPointerException

[英]Android NullPointerException with Parse Facebook Login

I'm a beginner developer with facebook-only login for my app, which links to Parse.com, and there's one bug that I can't fix. 我是一名初学者开发人员,我的应用程序仅使用Facebook登录,该应用程序链接到Parse.com,并且有一个我无法修复的错误。 Whenever the user is fully logged out of facebook, logging back in creates an NPE at the onActivityResult for ParseFacebookUtils.finishauthentication. 每当用户完全退出Facebook时,重新登录都会在onActivityResult上为ParseFacebookUtils.finishauthentication创建一个NPE。 I've seen a lot of similar questions answered, but none of the solutions worked for me. 我已经看到了很多类似的问题,但是没有一个解决方案对我有用。 Here's my code 这是我的代码

 public void parseLogin (){
    ParseFacebookUtils.logIn(this, new LogInCallback() {
          @Override
          public void done(ParseUser user, ParseException err) {
            if (user == null) {
             Log.d("SignIn", "Uh oh. The user cancelled the Facebook login.");
            } else  if (user.isNew()) {
              Log.d("SignIn", "User signed up and logged in through Facebook!");
            } else {
              Log.d("SignIn", "User logged in through Facebook!");
            }
          }
        });
    toStart();
 }

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    ParseFacebookUtils.finishAuthentication(requestCode, resultCode, data);
}

I've tried everything I can think of, and still can't avoid the NPE. 我已经尽力想尽一切办法,但仍然无法避免NPE。 Any new solutions would be greatly appreciated! 任何新的解决方案将不胜感激!

edit Here's the logcat 编辑这是logcat

03-31 16:23:39.938: E/AndroidRuntime(18322): FATAL EXCEPTION: main
03-31 16:23:39.938: E/AndroidRuntime(18322): java.lang.RuntimeException: Failure               delivering result ResultInfo{who=null, request=64206, result=-1, data=Intent { (has extras)   }} to activity {com.adit02/com.adit02.SignIn}: java.lang.NullPointerException
03-31 16:23:39.938: E/AndroidRuntime(18322):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2996)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3039)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at android.app.ActivityThread.access$1100(ActivityThread.java:124)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1178)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at android.os.Looper.loop(Looper.java:137)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at android.app.ActivityThread.main(ActivityThread.java:4440)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at java.lang.reflect.Method.invokeNative(Native Method)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at java.lang.reflect.Method.invoke(Method.java:511)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at dalvik.system.NativeStart.main(Native Method)
03-31 16:23:39.938: E/AndroidRuntime(18322): Caused by: java.lang.NullPointerException
03-31 16:23:39.938: E/AndroidRuntime(18322):    at com.parse.FacebookAuthenticationProvider.onActivityResult(FacebookAuthenticationProvider.java:171)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at com.parse.ParseFacebookUtils.finishAuthentication(ParseFacebookUtils.java:379)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at com.adit02.SignIn.onActivityResult(SignIn.java:103)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at android.app.Activity.dispatchActivityResult(Activity.java:4649)
03-31 16:23:39.938: E/AndroidRuntime(18322):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2992)

I figured it out. 我想到了。 The problem was I was logging in with facebook and parseFacebook at the same time, so the two authentications were conflicting at some times. 问题是我同时登录了facebook和parseFacebook,因此这两种身份验证有时会冲突。 While I couldn't get parseFacebook to work on its own, I just kept the facebook login and linked that facebook account with a parseUser (not through parseFacebookUtils). 虽然我无法让parseFacebook独自工作,但我只是保留了Facebook登录名,并将该Facebook帐户与parseUser关联(而不是通过parseFacebookUtils)。 This fixed the problem! 这样就解决了问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM