Androidruntime Error: Parcel: Unable to Marshal Value

AndroidRuntime error: Parcel: unable to marshal value

Your HashMap itself is serializable but is the Bottle class serializable? If not, it will not serialize and will throw errors at runtime.
Make the Bottle class implement the java.io.Serializable interface

Parcel: unable to marshal value

Your class should implement Parcelable (or Serializable, though Parcelable is the advised one on Android) to be able to pass the objects across Activity using the Intent.

Using Kotlin 1.1.4 and Android Extensions Plugin, you can add @Parcelize annotation to get the Parcelable implementation.

@Parcelize
class Player(var name: String?) : Parcelable {

// ...

Refer the blog post.

This feature is covered as experimental, so you have turn on an experimental flag in your build.gradle file:

androidExtensions {
experimental = true
}

Another option is to use this plugin to generate the boilerplate code necessary for the Parcelable implementation, but you should remember to update the implementation code everytime you change any properties in the class.

Or you can write your own Parcelable implementation.

AndroidRuntime error : Parcel unable to marshal value

You are trying to use writeParcel() to write an object that does not conform to the requirements stated in the documentation. You can only write values into a Parcel of the types stated in the javadoc.

java.lang.RuntimeException: Parcel: unable to marshal value com.package.NutritionInfo@84055e1

Implement the Parcelable interface like follows:

public class NutritionInfo extends SugarRecord<NutritionInfo> implements Parcelable {

public String nutritionName;
public String nutritionHeaderTitle;
public int nutritionCalories;
public boolean nutritionArchived;
public boolean nutritionChecked;

public NutritionInfo() {
}

public NutritionInfo(String name, String headerTitle, int cal, boolean isArchived, boolean isChecked) {
nutritionName = name;
nutritionHeaderTitle = headerTitle;
nutritionCalories = cal;
nutritionArchived = isArchived;
nutritionChecked = isChecked;
}

protected NutritionInfo(Parcel in) {
nutritionName = (String) in.readValue(null);
nutritionHeaderTitle = (String) in.readValue(null);
nutritionCalories = in.readInt();
nutritionArchived = in.readByte() != 0;
nutritionChecked = in.readByte() != 0;
}

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

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

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

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(nutritionName);
dest.writeValue(nutritionHeaderTitle);
dest.writeInt(nutritionCalories);
dest.writeByte((byte) (nutritionArchived ? 1 : 0));
dest.writeByte((byte) (nutritionChecked ? 1 : 0));
}
}

Do the same for your sugar record. And if the super class implements Parcelable you do not need to declare again in NutritionInfo, only implement the stuff.

Parcel: unable to marshal value com.google.firebase.firestore.DocumentReference

You are getting the following error:

"java.lang.RuntimeException: Parcel: unable to marshal value com.google.firebase.firestore.DocumentReference

Because your User class implements Parcelable, and all the fields inside it should also implement Parcelable, which doesn't, since both properties followers and following, are of type List<DocumentReference> and DocumentReference does not implement Parcelable, nor Serializable. To solve this, you should check my answer from the following post:

  • Firestore DocumentReference Serialization

And use the String path that exists in each DocumentReference object.

Parcel: unable to marshal value - Fragments

I'm guessing that you've messed up your activity's lifecycle methods. When you launch Google Maps, your activity's onPause(), onSaveInstanceState() and onStop() methods will be called. It is possible that you have messed up something in there. I don't see anything bad with what you've posted.

Android Runtime Error :Unable to marshal value

Do one thing and than try

public class Home extends Activity implements Serializable

remove implements Serializable from above line

And add

public class SettrGettr implements Serializable{
int ID;
String Name = "";
String FName = "";
String Class = "";
String UserName = "";
String Password = "";
String DOB = "";
String MobileNo = "";
String Relation = "";
ArrayList<SettrGettr> msttrList;

public ArrayList<SettrGettr> getMsttrList() {
return msttrList;
}

public void setMsttrList(ArrayList<SettrGettr> msttrList) {
this.msttrList = msttrList;
}

public int getID() {
return ID;
}

public void setID(int iD) {
ID = iD;
}

public String getName() {
return Name;
}

public void setName(String name) {
Name = name;
}

public String getFName() {
return FName;
}

public void setFName(String fName) {
FName = fName;
}

public String getCurrentClass() {
return Class;
}

public void setClass(String class1) {
Class = class1;
}

public String getUserName() {
return UserName;
}

public void setUserName(String userName) {
UserName = userName;
}

public String getPassword() {
return Password;
}

public void setPassword(String password) {
Password = password;
}

public String getDOB() {
return DOB;
}

public void setDOB(String dOB) {
DOB = dOB;
}

public String getMobileNo() {
return MobileNo;
}

public void setMobileNo(String mobileNo) {
MobileNo = mobileNo;
}

public String getRelation() {
return Relation;
}

public void setRelation(String relation) {
Relation = relation;
}

@Override
public String toString() {

return "\nRegistration No\t: " + getID() + "\n\nName\t\t\t\t\t\t\t: " + getName() + "\n\nFather Name\t\t\t: " + getFName() + "\n\nClass\t\t\t\t\t\t\t: "
+ getCurrentClass() + "\n\nCity\t\t\t\t\t\t\t\t: Islamabad" + "\n\nAdress\t\t\t\t\t\t: Islamabad";

}

}

Explanation:

When you are passing something serializable through bundle The value that you are passing it must Implements Serializable interface.

But you ware implementing Serializable interface from where you passing the value.



Related Topics



Leave a reply



Submit