當我嘗試在Kitkat上登錄facebook時,我得到一個NPE,在棒棒糖MR1上正常工作。我嘗試4.0.0和4.0.1Facebook SDK 4.0.1登錄NPE
我的登錄代碼:
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList(READ_PERMISSIONS));
飛機墜毀
java.lang.RuntimeException: Unable to start activity ComponentInfo{lt.segfoltas.psm/com.facebook.FacebookActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.facebook.login.LoginFragment.onCreate(LoginFragment.java:68)
at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:915)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1194)
at android.app.Activity.performStart(Activity.java:5258)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2171)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
相關清單項
<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" />
應用程序ID是設置在裏面創建
FacebookSdk.setApplicationId(FacebookData.APP_ID);
FacebookSdk.sdkInitialize(getApplicationContext());
立即在調用登錄後,我得到一個響應,登錄被取消。然後,應用程序崩潰。
Facebook的代碼,其中的崩潰就被報告:
this.callingPackage = this.getActivity().getCallingActivity().getPackageName();
我的權限:
private static final String[] READ_PERMISSIONS = new String[]{"public_profile", "user_events", "user_birthday", "email"};
[登錄博客的getLocation和電子郵件(http://stackoverflow.com/questions/29605236/login-facebook-getlocation-and-email)的可能重複,檢查出的答案,我想你會發現失去了什麼。 –