我使用 Facebook Android SDK 3.0 创建了一个 Android 应用程序。
我创建了一个工作应用程序(从 Eclipse 运行时)。它将创建一个 Facebook 会话(使用 com.facebook.UiLifecycleHelper)和一个登录按钮(使用 com.facebook.LoginButton),以便用户可以登录 Facebook。Facebook 身份验证对话框正在显示,填写凭据后,登录按钮将显示用户已登录 Facebook。
所以,到目前为止一切正常,但是当我进行发布构建(启用 Proguard)时,我得到以下异常:
E/AndroidRuntime(14690): FATAL EXCEPTION: main
E/AndroidRuntime(14690): com.facebook.FacebookException: Unable to save session.
E/AndroidRuntime(14690): at com.facebook.Session.saveSession(Session.java:673)
E/AndroidRuntime(14690): at com.facebook.UiLifecycleHelper.onSaveInstanceState(UiLifecycleHelper.java:124)
E/AndroidRuntime(14690): at com.peerkesoftware.blockcrusher.MorburActivity.onSaveInstanceState(MorburActivity.java:175)
E/AndroidRuntime(14690): at android.app.Activity.performSaveInstanceState(Activity.java:1147)
E/AndroidRuntime(14690): at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1216)
E/AndroidRuntime(14690): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3253)
E/AndroidRuntime(14690): at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3312)
E/AndroidRuntime(14690): at android.app.ActivityThread.access$900(ActivityThread.java:150)
E/AndroidRuntime(14690): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
E/AndroidRuntime(14690): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(14690): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(14690): at android.app.ActivityThread.main(ActivityThread.java:5191)
E/AndroidRuntime(14690): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(14690): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(14690): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
E/AndroidRuntime(14690): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
E/AndroidRuntime(14690): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(14690): Caused by: java.io.NotSerializableException: com.facebook.internal.SessionTracker$CallbackWrapper
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1364)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
E/AndroidRuntime(14690): at java.util.ArrayList.writeObject(ArrayList.java:644)
E/AndroidRuntime(14690): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(14690): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1053)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1404)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:979)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:368)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1074)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1404)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
E/AndroidRuntime(14690): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
E/AndroidRuntime(14690): at com.facebook.Session.saveSession(Session.java:671)
E/AndroidRuntime(14690): ... 16 more
我已经尝试添加一些 Proguard 规则,但没有解决这个问题:
-keep class com.facebook.*
-keep class com.facebook.android.*
-keep class android.webkit.WebViewClient
-keep class * extends android.webkit.WebViewClient
-keepclassmembers class * extends android.webkit.WebViewClient {
<methods>; }
有谁知道如何解决这个问题?