gpt4 book ai didi

android - BadParcelableException :ClassNotFoundException when unmarshalling: android. support.v4.app.FragmentManagerState

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:41:13 31 4
gpt4 key购买 nike

3 天前我已经迁移到 SDK Android 27.1.0,并且有一些像这样的崩溃,我不明白为什么。它(目前)出现在 Android 8 和 6 上。

BadParcelableException ClassNotFoundException when unmarshalling: android.support.v4.app.FragmentManagerState android.support.v4.app.Fragment.setUserVisibleHint

android.os.Parcel.readParcelableCreator (Parcel.java:2916)
android.os.Parcel.readParcelable (Parcel.java:2842)
android.os.Parcel.readValue (Parcel.java:2745)
android.os.Parcel.readArrayMapInternal (Parcel.java:3114)
android.os.BaseBundle.initializeFromParcelLocked (BaseBundle.java:273)
android.os.BaseBundle.unparcel (BaseBundle.java:226)
android.os.BaseBundle.putBoolean (BaseBundle.java:532)
arrow_right
android.support.v4.app.Fragment.setUserVisibleHint (Fragment.java:960)
android.support.v4.app.FragmentStatePagerAdapter.instantiateItem (FragmentStatePagerAdapter.java:121)
android.support.v4.view.ViewPager.addNewItem (ViewPager.java:1004)
android.support.v4.view.ViewPager.populate (ViewPager.java:1218)
android.support.v4.view.ViewPager.populate (ViewPager.java:1086)
android.support.v4.view.ViewPager$3.run (ViewPager.java:267)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:911)
android.view.Choreographer.doCallbacks (Choreographer.java:723)
android.view.Choreographer.doFrame (Choreographer.java:655)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:897)
android.os.Handler.handleCallback (Handler.java:790)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:6494)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)

这是我的适配器:

public abstract class CalendarPagerAdapter extends FragmentStatePagerAdapter {

private static final String TAG = LogUtils.makeLogTag(CalendarPagerAdapter.class);

protected DateTime mDateTime;
private final int mCount;
protected int mTodayPosition;

public static class CalendarContext {
public int mRange; // range = nb of days supported
public int mTodayPosition; // Today index in this area
public int mCurrentWeek; // Week number of today
public DateTime mFrom, mTo; // Compute from and to datetimes
public boolean mIsSundayFirstDay;

public CalendarContext(int area, int todayPosition, DateTime from, DateTime to,
int currentWeek, boolean isSundayFirstDay) {
mRange = area;
mTodayPosition = todayPosition;
mFrom = from;
mTo = to;
mCurrentWeek = currentWeek;
mIsSundayFirstDay = isSundayFirstDay;
}
}

public static CalendarContext computeAreaAndTodayPosition(int initialArea, int initialTodayPosition) {
// Compute min / max dates from now
DateTime from = new DateTime().minusDays(initialArea - initialTodayPosition).dayOfWeek().withMinimumValue();
DateTime to = new DateTime().plusDays(initialTodayPosition).dayOfWeek().withMaximumValue();

boolean isSundayFirstDay = false;
Calendar calendar = Calendar.getInstance(CompatUtils.getLocale(false));
if (calendar.getFirstDayOfWeek() == Calendar.SUNDAY) {
isSundayFirstDay = true;
from = from.minusDays(1);
to = to.minusDays(1);
}

LogUtils.LOGD("XXXX", "from dt=" + from.toString());
LogUtils.LOGD("XXXX", "to dt=" + to.toString());

// Compute nb days area supported
int daysRange = daysBetween(from, to).getDays() + 1;
LogUtils.LOGD("XXXX", "daysRange=" + daysRange);

// Compute today position
int todayPosition = daysBetween(from, DateTime.now().withTimeAtStartOfDay()).getDays() + 1;
LogUtils.LOGD("XXXX", "todayPosition=" + todayPosition);

int currentWeek = DateTime.now().getWeekOfWeekyear() - from.getWeekOfWeekyear();
LogUtils.LOGD("XXXX", "currentWeek=" + currentWeek);

return new CalendarContext(daysRange, todayPosition, from, to, currentWeek, isSundayFirstDay);
}

public CalendarPagerAdapter(FragmentManager mgr, int count, int todayPosition) {
super(mgr);
mDateTime = DateTime.now();
mCount = count;
mTodayPosition = todayPosition;
}

@Override
public int getCount() {
return mCount;
}

public boolean isTodayPosition(int position) {
return computeDifferenceDays(position) == 0;
}

public boolean isPastPosition(int position) {
return computeDifferenceDays(position) < 0;
}

public boolean isFuturPosition(int position) {
return computeDifferenceDays(position) > 0;
}

protected int computeDifferenceDays(int position) {
return position - getCalendarTodayPosition();
}

public long convertPositionToMs(int position) {
return convertPositionToMs(mDateTime, position);
}

public long convertMinPositionToMs() {
return convertPositionToMs(mDateTime, 0);
}

public long convertMaxPositionToMs() {
return convertPositionToMs(mDateTime, mCount - 1);
}

public String convertPositionToDate(int position) {
return TimeUnits.dateTimeToDateServer(new DateTime(convertPositionToMs(position)));
}

public long convertPositionToMs(DateTime datime, int position) {
int dayNum = computeDifferenceDays(position);
if (dayNum < 0)
return datime.minusDays(Math.abs(dayNum)).getMillis();
else if (dayNum > 0)
return datime.plusDays(Math.abs(dayNum)).getMillis();
else
return datime.getMillis();
}

public int convertMsToPosition(long millis) {
DateTime dtReceived = new DateTime(millis).withTimeAtStartOfDay();
return convertDateTimeToPosition(dtReceived);
}

public int convertDateTimeToPosition(DateTime dtReceived) {
DateTime now = DateTime.now().withTimeAtStartOfDay();
int nbDays = daysBetween(now, dtReceived).getDays();
return getCalendarTodayPosition() + nbDays;
}

public int getCalendarTodayPosition() {
return mTodayPosition;
}

public void shiftWithOffset(WeekDatePicker weekDatePicker, TextView weekDatePickerDayTextView,
DateTime currentSelectedDate, int offset) {
if (offset < 0 && mTodayPosition > 0) mTodayPosition += offset;
mDateTime = DateTime.now();
weekDatePicker.refreshTodayPosition();
weekDatePickerDayTextView.setText(TimeUnits.dateTimeToString(
currentSelectedDate, true, true, true, true, true));
}
}

你们有解决这个问题的想法吗?

非常感谢!

最佳答案

@XJIOP 说的是对的,我的产品也有同样的问题,但我无法找到崩溃的原因,我按照@XJIOP 路径并产生了错误,我通过更新紧凑版本解决了错误来自

appcompat 27.1.0 to 27.1.1

因为我使用的是混淆器,所以我还在我的混淆器中添加了以下行

如果您在生产构建中使用混淆器,请将以下行添加到混淆器中,否则忽略

-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}

在添加了 pro guard line 并更新了压缩库后,我能够解决这个问题,并且在我更新的生产版本中还没有报告错误。希望这会帮助其他人

关于android - BadParcelableException :ClassNotFoundException when unmarshalling: android. support.v4.app.FragmentManagerState,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49228979/

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