gpt4 book ai didi

android - 包裹 android.os.Parcel : Unmarshalling unknown type code

转载 作者:行者123 更新时间:2023-11-29 01:37:28 26 4
gpt4 key购买 nike

这是堆栈跟踪。

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shakti.mathssolver/com.mathssolver.pstrip.MainActivity}: java.lang.RuntimeException: Parcel android.os.Parcel@4215dec0: Unmarshalling unknown type code 7733356 at offset 24
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@4215dec0: Unmarshalling unknown type code 7733356 at offset 24
at android.os.Parcel.readValue(Parcel.java:2080)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2313)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getSparseParcelableArray(Bundle.java:1275)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:881)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1108)
at android.support.v4.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:1912)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:266)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:122)
at com.google.analyticscode.MyTrackerActivity.onCreate(MyTrackerActivity.java:21)
at com.google.billing.BillingHandlerLayerActivity.onCreate(BillingHandlerLayerActivity.java:36)
at com.mathssolver.pstrip.BaseSampleActivity.onCreate(BaseSampleActivity.java:164)
at com.mathssolver.pstrip.MainActivity.onCreate(MainActivity.java:96)
at android.app.Activity.performCreate(Activity.java:5248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(NativeStart.java)

这是我正在使用的 Parcelable 之一

public class QuesSolnInfo implements Parcelable {

private String strValue;
private Integer intValue;

public String ques;
public String ans;
public Bitmap ans_b;

/**
* Standard basic constructor for non-parcel
* object creation
*/
public QuesSolnInfo() { ; }


public QuesSolnInfo(String ques, String ans, Bitmap ans_b) {
this.ques = ques;
this.ans = ans;
this.ans_b = ans_b;
}

/**
*
* Constructor to use when re-constructing object
* from a parcel
*
* @param in a parcel from which to read this object
*/
public QuesSolnInfo(Parcel in) {
readFromParcel(in);
}

/**
* standard getter
*
* @return strValue
*/
public String getStrValue() {
return strValue;
}

/**
* Standard setter
*
* @param strValue
*/
public void setStrValue(String strValue) {
this.strValue = strValue;
}

/**
* standard getter
*
* @return
*/
public Integer getIntValue() {
return intValue;
}

/**
* Standard setter
*
* @param intValue
*/
public void setIntValue(Integer intValue) {
this.intValue = intValue;
}

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

@Override
public void writeToParcel(Parcel dest, int flags) {
if(ans_b == null || ques == null)
return;

// We just need to write each field into the
// parcel. When we read from parcel, they
// will come back in the same order
ans_b.writeToParcel(dest, 0);
dest.writeString(ques);
//dest.writeString(ans);
}

/**
*
* Called from the constructor to create this
* object from a parcel.
*
* @param in parcel from which to re-create object
*/
private void readFromParcel(Parcel in) {

// We just need to read back each
// field in the order that it was
// written to the parcel
in.setDataPosition(0);

try {
ans_b = Bitmap.CREATOR.createFromParcel(in);
ques = in.readString();
} catch (Exception e) { // TODO: handle exception
ans_b = null;
ques = null;
}
//ans = in.readString();
}

/**
*
* This field is needed for Android to be able to
* create new objects, individually or as arrays.
*
* This also means that you can use use the default
* constructor to create the object and use another
* method to hyrdate it as necessary.
*
* I just find it easier to use the constructor.
* It makes sense for the way my brain thinks ;-)
*
*/
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public QuesSolnInfo createFromParcel(Parcel in) {
return new QuesSolnInfo(in);
}

public QuesSolnInfo[] newArray(int size) {
return new QuesSolnInfo[size];
}
};

我的 proguard 文件中也有以下行,这是针对此处其他问题中其他类似问题的建议

-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;

最佳答案

请正确填写你的parcelable class,我在parcelable class中也犯了同样的错误,你也可以引用这个链接, RuntimeException: Parcel android.os.Parcel: Unmarshalling unknown type code when using android bundle

关于android - 包裹 android.os.Parcel : Unmarshalling unknown type code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27091507/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com