1

单击 com.facebook.widget.LoginButton 时出现以下错误:

06-04 09:47:47.142: E/AndroidRuntime(30567): FATAL EXCEPTION: main
06-04 09:47:47.142: E/AndroidRuntime(30567): java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.facebook.AuthorizationClient$AuthorizationRequest)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.os.Parcel.writeSerializable(Parcel.java:1279)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.os.Parcel.writeValue(Parcel.java:1233)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.os.Parcel.writeMapInternal(Parcel.java:591)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.os.Bundle.writeToParcel(Bundle.java:1619)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.os.Parcel.writeBundle(Parcel.java:605)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.content.Intent.writeToParcel(Intent.java:6660)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.content.pm.IPackageManager$Stub$Proxy.resolveIntent(IPackageManager.java:1904)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.app.ApplicationPackageManager.resolveActivityAsUser(ApplicationPackageManager.java:459)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.app.ApplicationPackageManager.resolveActivity(ApplicationPackageManager.java:453)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at com.facebook.Session.resolveIntent(Session.java:1067)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at com.facebook.Session.tryLoginActivity(Session.java:1053)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at com.facebook.Session.authorize(Session.java:890)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at com.facebook.Session.open(Session.java:957)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at com.facebook.Session.openForRead(Session.java:385)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at com.facebook.widget.LoginButton$LoginClickListener.onClick(LoginButton.java:641)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.view.View.performClick(View.java:4202)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.view.View$PerformClick.run(View.java:17340)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.os.Handler.handleCallback(Handler.java:725)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.os.Handler.dispatchMessage(Handler.java:92)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.os.Looper.loop(Looper.java:137)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.app.ActivityThread.main(ActivityThread.java:5039)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.lang.reflect.Method.invokeNative(Native Method)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.lang.reflect.Method.invoke(Method.java:511)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at dalvik.system.NativeStart.main(Native Method)
06-04 09:47:47.142: E/AndroidRuntime(30567): Caused by: java.io.NotSerializableException: com.mypackage.myapp.LoginActivity
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1364)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:979)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:368)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1074)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1404)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:979)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:368)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1074)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1404)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
06-04 09:47:47.142: E/AndroidRuntime(30567):    at android.os.Parcel.writeSerializable(Parcel.java:1274)
06-04 09:47:47.142: E/AndroidRuntime(30567):    ... 25 more

我遵循了 facebook 的本教程:https ://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrumptious/authenticate/ 但我没有使用片段,而是使用了 Activity。这可能与它有关吗?

该错误表示它正在尝试序列化我的 Activity,这很奇怪......在 Activity 中实现 Serializable 时,它​​会给出一个错误,指出 LoginButton 不可序列化。在 LoginButton 中实现它时,它会在另一个类上给出相同的错误,依此类推。

我的活动(我也通过了另一个生命周期:

@Override
protected void onResume() {
    super.onResume();
    Session session = Session.getActiveSession();
    if (session != null && (session.isOpened() || session.isClosed()) ) {
        call(session, session.getState(), null);
    }
    fbClient.onResume();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.fbClient = new UiLifecycleHelper(this, this);
    this.fbClient.onCreate(savedInstanceState);
            this.setContentView(R.layout.activity_login);
    this.btFacebook = (LoginButton)this.findViewById(R.id.login_facebook);
    this.btFacebook.setReadPermissions(new ArrayList<String>(){{ add("user_likes"); }});
}

@Override
public void call(Session session, SessionState state, Exception exception) {
    Log.i("LoginActivity", "call()");

    if (state.isOpened()) {
        Log.i("LoginActivity", "Logged in...");
    } else if (state.isClosed()) {
        Log.i("LoginActivity", "Logged out...");
    }
}
4

0 回答 0