title: Unmarshalling errors in Android app with custom parcelable classes
body: <p>For my Android application, I get several unmarshalling errors although I think I've done everything that is needed to properly save and load objects via <code>Parcelable</code>s. Can you tell me what's wrong with my code?</p>
  
  <p><strong>Error 1:</strong></p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo
  Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@41279860: Unmarshalling unknown type code 6619241 at offset 1372
  at android.os.Parcel.readValue(Parcel.java:1922)
  at android.os.Parcel.readMapInternal(Parcel.java:2094)
  at android.os.Bundle.unparcel(Bundle.java:223)
  at android.os.Bundle.getParcelable(Bundle.java:1158)
  at android.app.Activity.onCreate(Activity.java:860)
  at my.app.package.PlayComputer.onCreate(PlayComputer.java:1012)
  at android.app.Activity.performCreate(Activity.java:4465)
  </code></pre>
  
  <p>Line 1012 in <code>MyActivity</code> is the call to <code>super.onCreate(savedInstanceState);</code> in the <code>Activity</code>'s <code>onCreate()</code>.</p>
  
  <pre><code>protected void onSaveInstanceState(Bundle savedInstanceState) {
      if (myObject == null) {
          savedInstanceState.putParcelable("myObject", null);
      }
      else {
          savedInstanceState.putParcelable("myObject", myObject);
      }
      savedInstanceState.putInt(...);
      savedInstanceState.putString(...);
      savedInstanceState.putBoolean(...);
      super.onSaveInstanceState(savedInstanceState);
  }
  </code></pre>
  
  <p><code>myObject</code> is of class <code>MyObject</code> which has the following methods:</p>
  
  <pre><code>public void writeToParcel(Parcel out, int flags) {
      out.writeIntArray(...);
      out.writeInt(...);
      out.writeStringArray(...);
      out.writeString(...);
      out.writeParcelableArray(..., flags);
  }
  
  public static final Parcelable.Creator&lt;MyObject&gt; CREATOR = new Parcelable.Creator&lt;MyObject&gt;() {
      public MyObject createFromParcel(Parcel in) {
          try {
              if (in == null) {
                  return null;
              }
              else {
                  return new MyObject(in);
              }
          }
          catch (Exception e) {
              return null;
          }
      }
      public MyObject[] newArray(int size) {
          return new MyObject[size];
      }
  };
  
  private MyObject(Parcel in) {
      in.readIntArray(...);
      ... = in.readInt();
      in.readStringArray(...);
      ... = in.readString();
      ... = (OtherObject[]) in.readParcelableArray(OtherObject.class.getClassLoader());
  }
  </code></pre>
  
  <p><strong>Error 2:</strong></p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo
  Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling:
  at android.os.Parcel.readParcelable(Parcel.java:1971)
  at android.os.Parcel.readValue(Parcel.java:1859)
  at android.os.Parcel.readMapInternal(Parcel.java:2099)
  at android.os.Bundle.unparcel(Bundle.java:223)
  at android.os.Bundle.getParcelable(Bundle.java:1158)
  at android.app.Activity.onCreate(Activity.java:905)
  at my.app.package.PlayComputer.onCreate(SourceFile:1012)
  </code></pre>
  
  <p>Same files and classes.</p>
  
  <p><strong>Error 3:</strong></p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo
  Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@4051aff8: Unmarshalling unknown type code 7340149 at offset 1276
  at android.os.Parcel.readValue(Parcel.java:1913)
  at android.os.Parcel.readMapInternal(Parcel.java:2083)
  at android.os.Bundle.unparcel(Bundle.java:208)
  at android.os.Bundle.getParcelable(Bundle.java:1100)
  at my.app.package.PlayComputer.onCreate(SourceFile:1111)
  </code></pre>
  
  <p>This time, the causing line (1111) is the following one:</p>
  
  <pre><code>myObject = (MyObject) savedInstanceState.getParcelable("myObject");
  </code></pre>