gpt4 book ai didi

android - 解码 android.support.v7.widget.Toolbar$SavedState 时出现 ClassNotFoundException

转载 作者:IT王子 更新时间:2023-10-28 23:32:42 26 4
gpt4 key购买 nike

我在 Android 崩溃报告中看到以下错误:

android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v7.widget.Toolbar$SavedState
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2318)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3974)
at android.app.ActivityThread.access$900(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1299)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v7.widget.Toolbar$SavedState
at android.os.Parcel.readParcelableCreator(Parcel.java:2154)
at android.os.Parcel.readParcelable(Parcel.java:2104)
at android.os.Parcel.readValue(Parcel.java:2020)
at android.os.Parcel.readSparseArrayInternal(Parcel.java:2382)
at android.os.Parcel.readSparseArray(Parcel.java:1742)
at android.os.Parcel.readValue(Parcel.java:2077)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2321)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getSparseParcelableArray(Bundle.java:1273)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1744)
at android.app.Activity.onRestoreInstanceState(Activity.java:1017)
at android.app.Activity.performRestoreInstanceState(Activity.java:989)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1138)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2284)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3974)
at android.app.ActivityThread.access$900(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1299)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(NativeStart.java)

恢复 Activity 时似乎会间歇性发生。我没有在任何代码中直接访问 SavedState 类。

编辑:我的 Activity 的布局 Xml 是

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">

<include layout="@layout/toolbar" />
....

工具栏 XML 是

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

在我的 Activity 的 onCreate 中我会这样做

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_show_txn);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

localBroadcastManager = LocalBroadcastManager.getInstance(getApplicationContext());
mResources = getResources();

if (savedInstanceState != null) {
long id = savedInstanceState.getLong(STA_TXN_ID);
...
} else {
... read fresh
}

mDateTV = (TextView) findViewById(R.id.ASTVDate);
mDayTV = (TextView) findViewById(R.id.ASTVDay);
mCatName = (TextView) findViewById(R.id.ASTVCatName);
mMonthTV = (TextView) findViewById(R.id.ASTVMonth);
....

Calendar c = java.util.Calendar.getInstance();
c.setTime(txn.getTxnDate());
mDateTV.setText("" + c.get(Calendar.DAY_OF_MONTH));
mDayTV.setText(c.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US));
mMonthTV.setText(c.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.US));
}

我一直在使用 appcompat-v7:22.1.1,是的,我在 proguard 之后收到了这些错误。

最佳答案

看起来以下问题正是关于它的: https://code.google.com/p/android/issues/detail?id=196430

关于android - 解码 android.support.v7.widget.Toolbar$SavedState 时出现 ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30028668/

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