I am trying to use the Parceler library for Android.
However I am getting the following error when trying to use it on a couple of my Java objects, this is the error I am getting:
java.lang.RuntimeException: Parcel: unable to marshal value
Here is the class that it seems to be failing on:
//MyObject.java
@Parcel
public class MyObject {
@SerializedName("name")
String displayName;
@SerializedName("address")
String displayAddress;
@SerializedName("css")
MyTheme theme;
@SerializedName("myList")
ArrayList<String> myList;
MyDetails myDetails;
// empty constructor needed by the Parceler library
public MyObject(){
}
//Various Getters and Setters, some manipulate data
Here is the MyTheme class:
@Parcel
public class MyTheme {
@SerializedName("backgroundColor")
String backgroundColor;
@SerializedName("textColor")
String textColor;
// empty constructor needed by the Parceler library
public MyTheme(){
}
//Various getters and setters and some non getter/setter methods
And here is the MyDetails class:
@Parcel
public class MyDetails {
@SerializedName("description")
@SerializedName("addressTypes")
ArrayList<String> addressTypes;
// empty constructor needed by the Parceler library
public MyDetails(){
}
//Various getter methods
Finally I use the the MyObject Object in two ways, one where I send an ArrayList of MyObjects and again where I send a single one, as follows:
//ArrayList
ArrayList<MyObject> myObjects = ...
intent.putExtra(INTENT_EXTRA_OBJECTS, Parcels.wrap(myObjects));
//Retrieving
merchants = Parcels.unwrap(getIntent().getParcelableExtra(INTENT_EXTRA_OBJECTS));
//Single Object
MyObject myObject = ...;
args.putParcelable(ARG_OBJECT, Parcels.wrap(myObject));
//Retrieving
myObject = Parcels.unwrap(getArguments().getParcelable(ARG_OBJECT));
The error is very ambiguous and I am not sure how to debug it or find a solution, can anyone point to where the issue might be in my code?