Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialYuan Xue Lim
4,479 PointsStormy app crashed (android.os.BadParcelableException: ClassNotFoundException when unmarshalling)
Hi all,
I have been trying to troubleshoot this problem for the whole night.I was able to pinpoint where the app crashes using the debugger.
It is this line:
Parcelable[] parcelables = intent.getParcelableArrayExtra(MainActivity.HOURLY_FORECAST);
This is the only error message I could find on the debugger :
"android.os.BadParcelableException: ClassNotFoundException when unmarshalling:"
Thanks in advance.
1 Answer
Yuan Xue Lim
4,479 PointsI've solved it on my own.
Apparently, having parcel read/write in different order can cause the error which is "Consumer closed input channel or an error occurred"
In the Hour class, the order in which you "write" in the method "writeToParcel" must match the order you wrote in private Hour(Parcel in) object.
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(mTime);
dest.writeDouble(mTemperature);
dest.writeString(mSummary);
dest.writeString(mIcon);
dest.writeString(mTimeZone);
}
private Hour(Parcel in){
mTime=in.readLong();
mTemperature=in.readDouble();
mSummary=in.readString();
mIcon=in.readString();
mTimeZone =in.readString();
}
Unsubscribed User
48,988 PointsUnsubscribed User
48,988 Pointsthanks had the same error