java.lang.IllegaLStateException:Source.readString() mest not be null

马上都要去演示了,进入订单列表页面,总是崩溃,错误日志如下文所示: 

java.lang.RuntimeException: Unable to start activity ComponentInfo{cn.com.henansoft.tripbus/cn.com.henansoft.tripbus.ui.rent.RentCarActivity}: java.lang.IllegalStateException: source.readString() must not be null
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2470)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2532)
    at android.app.ActivityThread.access$900(ActivityThread.java:169)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
    at android.os.Handler.dispatchMessage(Handler.java:111)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5562)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:968)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:763)
 Caused by: java.lang.IllegalStateException: source.readString() must not be null
    at cn.com.henansoft.tripbus.bean.Order.<init>(Order.kt:30)
    at cn.com.henansoft.tripbus.bean.Order$Companion$CREATOR$1.createFromParcel(Order.kt:58)
    at cn.com.henansoft.tripbus.bean.Order$Companion$CREATOR$1.createFromParcel(Order.kt:57)
    at android.os.Parcel.readParcelable(Parcel.java:2246)
    at android.os.Parcel.readValue(Parcel.java:2146)
    at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
    at android.os.BaseBundle.unparcel(BaseBundle.java:224)
    at android.os.BaseBundle.getBoolean(BaseBundle.java:662)
    at android.os.Bundle.getBoolean(Bundle.java:603)
    at android.content.Intent.getBooleanExtra(Intent.java:4900)
    at cn.com.henansoft.tripbus.ui.rent.RentCarActivity.initView(RentCarActivity.kt:65)
    at cn.com.henansoft.tripbus.base.BaseActivity.onCreate(BaseActivity.java:107)
    at android.app.Activity.performCreate(Activity.java:6029)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2532) 
    at android.app.ActivityThread.access$900(ActivityThread.java:169) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421) 
    at android.os.Handler.dispatchMessage(Handler.java:111) 
    at android.os.Looper.loop(Looper.java:194) 
    at android.app.ActivityThread.main(ActivityThread.java:5562) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:968) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:763)

项目使用kotlin写的,没有想那么多,然后再StackOverflow上搜索,找到一个类似的问题:https://stackoverflow.com/questions/45688232/illegalstateexception-parcel-readstring-must-not-be-null ;意思是:目前,唯一的解决方法是使实现parcelable的类的成员可以为空。但是就算这样处理了,还是报错。

最后根据接口返回数据发现,接口返回数据缺少一些对应字段,所以parcelable的类的成员为空。

猜你喜欢

转载自my.oschina.net/deepSprings/blog/1635658
今日推荐