0

So I've checked over a lot of different posts and I'm still not finding a solution for this problem. It's probably something small that I'm just not noticing, but I figured I'd get additional sets of eyes on the issue :)

Model object in one of my library projects:

  public class Venue implements Parcelable {

    private String id;
    private String city;
    private String state;
    private String name;
    private String category;
    private String subcategory;
    private double latitude;
    private double longitude;
    private List<Venue> related;

    public Venue() {

    }

    public Venue( Parcel parcel ) {
        id = parcel.readString();
        city = parcel.readString();
        state = parcel.readString();
        name = parcel.readString();
        category = parcel.readString();
        subcategory = parcel.readString();
        latitude = parcel.readDouble();
        longitude = parcel.readDouble();
        related = new ArrayList<Venue>();
        parcel.readTypedList( related, Venue.CREATOR );
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getSubcategory() {
        return subcategory;
    }

    public void setSubcategory(String subcategory) {
        this.subcategory = subcategory;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public List<Venue> getRelated() {
        return related;
    }

    public void setRelated(List<Venue> related) {
        this.related = related;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString( id );
        dest.writeString( city );
        dest.writeString( state );
        dest.writeString( name );
        dest.writeString( category );
        dest.writeString( subcategory );
        dest.writeDouble( latitude );
        dest.writeDouble( longitude );
        dest.writeTypedList( related );
    }

    public static final Creator<Venue> CREATOR = new Creator<Venue>() {
        @Override
        public Venue createFromParcel(Parcel source) {
            return new Venue( source );
        }

        @Override
        public Venue[] newArray(int size) {
            return new Venue[size];
        }
    };
    }

Method that's causing the crash in my Android project. If I comment out outState.putParcelable, it stops crashing:

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if( mVenue != null ) {
        outState.putParcelable( EXTRA_VENUE, mVenue );
    }
}

Logcat output:

E/Parcel﹕ Class not found when unmarshalling: com.companyname.android.model.schedule.Venue
    java.lang.ClassNotFoundException: com.companyname.android.model.schedule.Venue
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:251)
            at android.os.Parcel.readParcelableCreator(Parcel.java:2133)
            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.getBundle(Bundle.java:1184)
            at gui.a(SourceFile:74)
            at ouj.a(Unknown Source)
            at grv.onTransact(SourceFile:89)
            at android.os.Binder.transact(Binder.java:361)
            at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreate(Unknown Source)
            at com.google.android.gms.maps.SupportMapFragment$a.onCreate(Unknown Source)
            at com.google.android.gms.dynamic.a$3.b(Unknown Source)
            at com.google.android.gms.dynamic.a$1.a(Unknown Source)
            at com.google.android.gms.maps.SupportMapFragment$b.ip(Unknown Source)
            at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
            at com.google.android.gms.dynamic.a.a(Unknown Source)
            at com.google.android.gms.dynamic.a.onCreate(Unknown Source)
            at com.google.android.gms.maps.SupportMapFragment.onCreate(Unknown Source)
            at .... 

What I've tried to fix the issue:

Using parcel.readList rather than readTypedList and removing all lines in the constructor with the parcel and the writeToParcel line to see if that at least stopped crashes temporarily (it doesn't)

Any suggestions would be really appreciated.

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95
Paul Ruiz
  • 2,396
  • 3
  • 27
  • 47
  • 1
    Have you tried changing from readTypeList(_,_) to readArrayList(Venue.class.getClassLoader()), and changing writeTypedList(_) to writeArrayList(_)? I've seen a lot of issues using the "typed" list APIs because the wrong class loader is being used. – bstar55 Jun 30 '14 at 21:58
  • Thanks. I tried that but still having an issue. Going to keep playing with it to see if I can't get it to work. Going to look into the path configuration stuff and see if I can understand the other answer in this post :) – Paul Ruiz Jun 30 '14 at 22:17

2 Answers2

1

Thanks for the input everyone. I figured out the issue - it's the fact that we're using a MapFragment that doesn't like our venue parcelable. Found the answer here:

BadParcelableException in google maps code

Community
  • 1
  • 1
Paul Ruiz
  • 2,396
  • 3
  • 27
  • 47
0

This kind of error is usually motivated by some mistake on path configuration. Check if your configuration path correct, and also if you have deploy configurations, make sure that the class Venue is configured to be deployed.

Roger
  • 1