2

我们正面临一个 BadParceableException,我们不知道为什么。上面是堆栈跟踪:

    Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.my.app/br.com.my.app.commons.ui.MainActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: androidx.appcompat.widget.AppCompatSpinner$SavedState
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2789)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2872)
       at android.app.ActivityThread.-wrap11()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1595)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6543)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)

Caused by android.os.BadParcelableException: ClassNotFoundException when unmarshalling: androidx.appcompat.widget.AppCompatSpinner$SavedState
       at android.os.Parcel.readParcelableCreator(Parcel.java:2925)
       at android.os.Parcel.readParcelable(Parcel.java:2851)
       at android.view.AbsSavedState.<init>(AbsSavedState.java:67)
       at android.view.View$BaseSavedState.<init>(View.java:25139)
       at android.view.View$BaseSavedState.<init>(View.java:25128)
       at br.com.my.app.commons.ui.custom.DefaultOptionSpinner$SavedState.<init>(DefaultOptionSpinner.java:193)
       at br.com.my.app.commons.ui.custom.DefaultOptionSpinner$SavedState.<init>(DefaultOptionSpinner.java:185)
       at br.com.my.app.commons.ui.custom.DefaultOptionSpinner$SavedState$1.createFromParcel(DefaultOptionSpinner.java:206)
       at br.com.my.app.commons.ui.custom.DefaultOptionSpinner$SavedState$1.createFromParcel(DefaultOptionSpinner.java:204)
       at android.os.Parcel.readParcelable(Parcel.java:2860)
       at android.os.Parcel.readValue(Parcel.java:2754)
       at android.os.Parcel.readSparseArrayInternal(Parcel.java:3204)
       at android.os.Parcel.readSparseArray(Parcel.java:2416)
       at android.os.Parcel.readValue(Parcel.java:2811)
       at android.os.Parcel.readArrayMapInternal(Parcel.java:3123)
       at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:273)
       at android.os.BaseBundle.unparcel(BaseBundle.java:226)
       at android.os.Bundle.getSparseParcelableArray(Bundle.java:1009)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:772)
       at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
       at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
       at androidx.fragment.app.FragmentManagerImpl.dispatchCreate(FragmentManagerImpl.java:2607)
       at androidx.fragment.app.FragmentController.dispatchCreate(FragmentController.java:235)
       at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:316)
       at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:115)
       at br.com.zalf.prolog.commons.ui.MainActivity.onCreate(MainActivity.java:129)
       at android.app.Activity.performCreate(Activity.java:7009)
       at android.app.Activity.performCreate(Activity.java:7000)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2742)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2872)
       at android.app.ActivityThread.-wrap11()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1595)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6543)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)

我们在 stackoverflow 中看到了一些类似的错误,但没有人真正为我们工作。

异常是说错误发生在此类中的“super(in)”处:

私有静态类 SavedState 扩展 BaseSavedState { int mSelectedPosition;

SavedState(Parcelable superState) {
    super(superState);
}

private SavedState(android.os.Parcel in) {
    super(in);
    this.mSelectedPosition = in.readInt();
}

@Override
public void writeToParcel(android.os.Parcel out, int flags) {
    super.writeToParcel(out, flags);
    out.writeInt(this.mSelectedPosition);
}

public static final Parcelable.Creator<SavedState> CREATOR =
        new Parcelable.Creator<SavedState>() {
            public SavedState createFromParcel(android.os.Parcel in) {
                return new SavedState(in);
            }

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

}

有没有人有任何想法可以帮助我们?

谢谢!

4

0 回答 0