Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Android Lists and Adapters (2015) Using Parcelable Data Retrieving Parcelable Data

FATAL EXCEPTION: main

I got this error when I pressed on the "7 day" button: <code> 06-15 16:10:59.326 1895-1895/net.cduck.stormy E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: net.cduck.stormy, PID: 1895 java.lang.RuntimeException: Unable to start activity ComponentInfo{net.cduck.stormy/net.cduck.stormy.ui.DailyForcastActivity}: android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object called CREATOR on class net.cduck.stormy.weather.Day at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) 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:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5257) 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:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object called CREATOR on class net.cduck.stormy.weather.Day at android.os.Parcel.readParcelableCreator(Parcel.java:2304) at android.os.Parcel.readParcelable(Parcel.java:2245) at android.os.Parcel.readParcelableArray(Parcel.java:2338) at android.os.Parcel.readValue(Parcel.java:2206) at android.os.Parcel.readArrayMapInternal(Parcel.java:2485) at android.os.BaseBundle.unparcel(BaseBundle.java:221) at android.os.Bundle.getParcelableArray(Bundle.java:777) at android.content.Intent.getParcelableArrayExtra(Intent.java:5102) at net.cduck.stormy.ui.DailyForcastActivity.onCreate(DailyForcastActivity.java:24) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)             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:1303)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:135)             at android.app.ActivityThread.main(ActivityThread.java:5257)             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:903)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)</code>

How do I fix this?

1 Answer

I figured it out. This line was causing the error in my DayAdapter class:

```holder.temperatureLabel.setText(day.getTemperatureMax() + "");

After commenting this line out and adding this try-catch block, my code did not crash: try { holder.temperatureLabel.setText(day.getTemperatureMax() + "");

```        catch (Exception e){
```            Log.e(TAG, "Fatal Exception", e);
```        }