calendar在跑monkey测试时出现异常停止
时间:10-02
整理:3721RD
点击:
[DESCRIPTION]
Calendar在跑monkey test的时候出现force close,异常停止
[SOLUTION]
root cause: Parcelable class( RecurrenceModel )未实现creator接口造成的
如何判断是一样的问题?
对比下面的callstack, 如果是报出了“android.os.BadParcelableException: Parcelable protocol requires a
Parcelable.Creator object called CREATOR on class
com.android.calendar.recurrencepicker.RecurrencePickerDialog$RecurrenceModel”的信息,则说明是相同的问题
,可以使用该解决方案。
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.android.calendar/com.android.calendar.event.EditEventActivity}:
android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object called
CREATOR on class com.android.calendar.recurrencepicker.RecurrencePickerDialog$RecurrenceModel
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
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:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object
called CREATOR on class com.android.calendar.recurrencepicker.RecurrencePickerDialog$RecurrenceModel
at android.os.Parcel.readParcelableCreator(Parcel.java:2156)
at android.os.Parcel.readParcelable(Parcel.java:2097)
at android.os.Parcel.readValue(Parcel.java:2013)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2314)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getSparseParcelableArray(Bundle.java:1273)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:827)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1044)
at android.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:1848)
at android.app.Activity.onCreate(Activity.java:902)
at com.android.calendar.event.EditEventActivity.onCreate(EditEventActivity.java:72)
at android.app.Activity.performCreate(Activity.java:5264)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
... 11 more
Solution: 在RecurrenceModel class中添加creator接口实现:
修改RecurrencePickerDialog.java文件,在RecurrenceModel class中添加下面的
method:
/**M: add CREATOR. @{*/
public final Parcelable.Creator<RecurrenceModel> CREATOR =
new Creator<RecurrencePickerDialog.RecurrenceModel>() {
@Override
public RecurrenceModel[] newArray(int size) {
return new RecurrenceModel[size];
}
@Override
public RecurrenceModel createFROMParcel(Parcel source) {
RecurrenceModel info = new RecurrenceModel();
info.initFromParcel(source);
return info;
}
};
protected void initFromParcel(Parcel source) {
freq=source.readInt();
interval=source.readInt();
end=source.readInt();
endDate.year=source.readInt();
endDate.month=source.readInt();
endDate.monthDay=source.readInt();
endCount=source.readInt();
source.readBooleanArray(weeklyByDayOfWeek);
monthlyRepeat=source.readInt();
monthlyByMonthDay=source.readInt();
monthlyByDayOfWeek=source.readInt();
monthlyByNthDayOfWeek=source.readInt();
recurrenceState=source.readInt();
}
/**@}*/
Calendar在跑monkey test的时候出现force close,异常停止
[SOLUTION]
root cause: Parcelable class( RecurrenceModel )未实现creator接口造成的
如何判断是一样的问题?
对比下面的callstack, 如果是报出了“android.os.BadParcelableException: Parcelable protocol requires a
Parcelable.Creator object called CREATOR on class
com.android.calendar.recurrencepicker.RecurrencePickerDialog$RecurrenceModel”的信息,则说明是相同的问题
,可以使用该解决方案。
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.android.calendar/com.android.calendar.event.EditEventActivity}:
android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object called
CREATOR on class com.android.calendar.recurrencepicker.RecurrencePickerDialog$RecurrenceModel
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
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:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object
called CREATOR on class com.android.calendar.recurrencepicker.RecurrencePickerDialog$RecurrenceModel
at android.os.Parcel.readParcelableCreator(Parcel.java:2156)
at android.os.Parcel.readParcelable(Parcel.java:2097)
at android.os.Parcel.readValue(Parcel.java:2013)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2314)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getSparseParcelableArray(Bundle.java:1273)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:827)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1044)
at android.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:1848)
at android.app.Activity.onCreate(Activity.java:902)
at com.android.calendar.event.EditEventActivity.onCreate(EditEventActivity.java:72)
at android.app.Activity.performCreate(Activity.java:5264)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
... 11 more
Solution: 在RecurrenceModel class中添加creator接口实现:
修改RecurrencePickerDialog.java文件,在RecurrenceModel class中添加下面的
method:
/**M: add CREATOR. @{*/
public final Parcelable.Creator<RecurrenceModel> CREATOR =
new Creator<RecurrencePickerDialog.RecurrenceModel>() {
@Override
public RecurrenceModel[] newArray(int size) {
return new RecurrenceModel[size];
}
@Override
public RecurrenceModel createFROMParcel(Parcel source) {
RecurrenceModel info = new RecurrenceModel();
info.initFromParcel(source);
return info;
}
};
protected void initFromParcel(Parcel source) {
freq=source.readInt();
interval=source.readInt();
end=source.readInt();
endDate.year=source.readInt();
endDate.month=source.readInt();
endDate.monthDay=source.readInt();
endCount=source.readInt();
source.readBooleanArray(weeklyByDayOfWeek);
monthlyRepeat=source.readInt();
monthlyByMonthDay=source.readInt();
monthlyByDayOfWeek=source.readInt();
monthlyByNthDayOfWeek=source.readInt();
recurrenceState=source.readInt();
}
/**@}*/