java.io.NotSerializableException

保存对象至perference中出现的问题

03-14 09:12:37.789 999-999/com.unicair.hancher.newsapp W/System.err: java.io.WriteAbortedException: Read an exception; java.io.NotSerializableException: com.unicair.hancher.newsapp.weather.WeatherEntity$Basic
03-14 09:12:37.790 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:778)
03-14 09:12:37.790 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1983)
03-14 09:12:37.790 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1940)
03-14 09:12:37.790 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1113)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:454)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1345)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1242)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1835)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:761)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1983)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1940)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at com.unicair.hancher.newsapp.setting.PerferenceUtil.getSerializableObject(PerferenceUtil.java:102)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at com.unicair.hancher.newsapp.weather.WeatherFragment.initLineChartData(WeatherFragment.java:101)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at com.unicair.hancher.newsapp.weather.WeatherFragment.onCreateView(WeatherFragment.java:86)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at android.app.Fragment.performCreateView(Fragment.java:2220)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at android.app.BackStackRecord.run(BackStackRecord.java:793)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:562)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at android.support.v13.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:149)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at android.support.v4.view.ViewPager.populate(ViewPager.java:1239)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at android.support.v4.view.ViewPager.populate(ViewPager.java:1087)
03-14 09:12:37.791 999-999/com.unicair.hancher.newsapp W/System.err:     at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1613)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.View.measure(View.java:18817)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.widget.LinearLayout.measureVertical(LinearLayout.java:901)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.View.measure(View.java:18817)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5970)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.View.measure(View.java:18817)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5970)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.View.measure(View.java:18817)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5970)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.View.measure(View.java:18817)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5970)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.View.measure(View.java:18817)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5970)
03-14 09:12:37.792 999-999/com.unicair.hancher.newsapp W/System.err:     at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2652)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.View.measure(View.java:18817)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6026)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.Choreographer.doCallbacks(Choreographer.java:670)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.Choreographer.doFrame(Choreographer.java:606)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.os.Handler.handleCallback(Handler.java:739)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.os.Looper.loop(Looper.java:148)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5417)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err: Caused by: java.io.NotSerializableException: com.unicair.hancher.newsapp.weather.WeatherEntity$Basic
03-14 09:12:37.793 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at com.unicair.hancher.newsapp.setting.PerferenceUtil.setSerializableObject(PerferenceUtil.java:47)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at com.unicair.hancher.newsapp.weather.WeatherFragment$UpdateChartDataHandler.handleMessage(WeatherFragment.java:57)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
03-14 09:12:37.794 999-999/com.unicair.hancher.newsapp W/System.err:    ... 5 more

额~~
下文说没实现接口 implements Serializable
https://www.cnblogs.com/yuefenghui/p/5551583.html
检查,额,这种低级错误,我可能会犯吗

https://www.cnblogs.com/lcchuguo/p/4777576.html
撒~这个靠谱
要么内部类必须是静态的
要么改写成一个单独的类然后实现方法

你可能感兴趣的:(bug)