Android:android.os.BadParcelableException:解组时的ClassNotFoundException:asc

时间:2017-06-01 01:40:36

标签: java android exception parcelable

我很难在我的应用中尝试调试此崩溃。它说它是解组asc,但我不知道asc是什么。我该如何寻找线索?我很感激..

堆栈追踪:

main Exception: Unable to start activity ComponentInfo{com.myapp.MainActivity}: 
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: asc 
Stack: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.MainActivity}: 
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: asc 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6121) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by: 
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: asc 
at android.os.Parcel.readParcelableCreator(Parcel.java:2536) 
at android.os.Parcel.readParcelable(Parcel.java:2462) 
at android.os.Parcel.readValue(Parcel.java:2365) 
at android.os.Parcel.readSparseArrayInternal(Parcel.java:2813) 
at android.os.Parcel.readSparseArray(Parcel.java:2068) 
at android.os.Parcel.readValue(Parcel.java:2422) 
at android.os.Parcel.readArrayMapInternal(Parcel.java:2732) 
at android.os.BaseBundle.unparcel(BaseBundle.java:269) 
at android.os.Bundle.getSparseParcelableArray(Bundle.java:934) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1208) 
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595) 
at android.support.v4.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:2893) 
at android.support.v4.app.FragmentController.dispatchCreate(FragmentController.java:190) 
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:353) 
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:85) 
at com.myapp.BaseActivity.onCreate(BaseActivity.java:36) 
at com.myapp.MainActivity.onCreate(MainActivity.java:190) 
at android.app.Activity.performCreate(Activity.java:6682) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619) ... 9 more

这是我项目中唯一的自定义Parcelable类:

public class SuggestLocationObject implements Parcelable {

    private ArrayList<Float> mLng_lat;
    private String mCountryLong;
    private String mCountry;
    private float mTimeZone;
    private String mRegion;
    private String mCity;

    public SuggestLocationObject(){

    }

    public String getCountryLong() {
        return mCountryLong;
    }

    public void setCountryLong(String countryLong) {
        mCountryLong = countryLong;
    }

    public String getCountry() {
        return mCountry;
    }

    public void setCountry(String country) {
        mCountry = country;
    }

    public float getTimeZone() {
        return mTimeZone;
    }

    public void setTimeZone(float timeZone) {
        mTimeZone = timeZone;
    }

    public String getRegion() {
        return mRegion;
    }

    public void setRegion(String region) {
        mRegion = region;
    }

    public String getCity() {
        return mCity;
    }

    public void setCity(String city) {
        mCity = city;
    }


    public ArrayList<Float> getLng_lat() {
        return mLng_lat;
    }

    public void setLng_lat(ArrayList<Float> lng_lat) {
        mLng_lat = lng_lat;
    }

    public void setLatitudeAndLongitude(float latitude, float longitude) {
        mLng_lat = new ArrayList<>(2);
        mLng_lat.add(longitude);
        mLng_lat.add(latitude);
    }

    // Parcelable Code Starts Here -----------------------
    protected SuggestLocationObject(Parcel in) {
        if (in.readByte() == 0x01) {
            mLng_lat = new ArrayList<Float>();
            in.readList(mLng_lat, Float.class.getClassLoader());
        } else {
            mLng_lat = null;
        }
        mCountryLong = in.readString();
        mCountry = in.readString();
        mTimeZone = in.readFloat();
        mRegion = in.readString();
        mCity = in.readString();
    }

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

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        if (mLng_lat == null) {
            dest.writeByte((byte) (0x00));
        } else {
            dest.writeByte((byte) (0x01));
            dest.writeList(mLng_lat);
        }
        dest.writeString(mCountryLong);
        dest.writeString(mCountry);
        dest.writeFloat(mTimeZone);
        dest.writeString(mRegion);
        dest.writeString(mCity);
    }

    @SuppressWarnings("unused")
    public static final Parcelable.Creator<SuggestLocationObject> CREATOR = new Parcelable.Creator<SuggestLocationObject>() {
        @Override
        public SuggestLocationObject createFromParcel(Parcel in) {
            return new SuggestLocationObject(in);
        }

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

0 个答案:

没有答案