我是一名 Android 开发人员,我正在Serializable
尝试Activity
使用Bundle
. 但是,我得到以下 -Parcelable encountered ClassNotFoundException reading a Serializable object
作为错误。
这是什么原因,我该如何解决?
下面是代码片段:
Bundle previousData = new Bundle();
previousData.putSerializable("GetVehicleInfo_AllTrims", trimsObj);// trimObj is a serialized object
Intent detailsIntent = new Intent(androidScrolbleTabbar.TABBAR_PUSHVIEW);
detailsIntent.putExtras(previousData);
detailsIntent.putExtra("ActivityIdentifier", ManualScreenNav2.viewIdentifier);
detailsIntent.putExtra("className", ManualScreenNav2.class.getName());
sendBroadcast(detailsIntent);
以下是完整的堆栈跟踪:
03-19 15:39:02.549: E/AndroidRuntime(27084): FATAL EXCEPTION: main
03-19 15:39:02.549: E/AndroidRuntime(27084): java.lang.RuntimeException: Error receiving broadcast Intent { act=com.mobyfactory.pushview (has extras) } in com.adplotmanagement.androidScrolbleTabbar$PUSHViewBroadcastReceiver@461bc340
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:942)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.os.Handler.handleCallback(Handler.java:587)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.os.Handler.dispatchMessage(Handler.java:92)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.os.Looper.loop(Looper.java:143)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.app.ActivityThread.main(ActivityThread.java:4701)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.lang.reflect.Method.invoke(Method.java:521)
03-19 15:39:02.549: E/AndroidRuntime(27084): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-19 15:39:02.549: E/AndroidRuntime(27084): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-19 15:39:02.549: E/AndroidRuntime(27084): at dalvik.system.NativeStart.main(Native Method)
03-19 15:39:02.549: E/AndroidRuntime(27084): Caused by: java.lang.RuntimeException: Parcelable encounteredClassNotFoundException reading a Serializable object (name = com.halcyon.ui.redbumper.entities.RBGetVehicleInfoByVin_AllTrims)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.os.Parcel.readSerializable(Parcel.java:1951)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.os.Parcel.readValue(Parcel.java:1822)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.os.Parcel.readMapInternal(Parcel.java:2008)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.os.Bundle.unparcel(Bundle.java:208)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.os.Bundle.getString(Bundle.java:1034)
03-19 15:39:02.549: E/AndroidRuntime(27084): at com.adplotmanagement.androidScrolbleTabbar$PUSHViewBroadcastReceiver.onReceive(androidScrolbleTabbar.java:560)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:910)
03-19 15:39:02.549: E/AndroidRuntime(27084): ... 9 more
03-19 15:39:02.549: E/AndroidRuntime(27084): Caused by: java.lang.ClassNotFoundException: com.halcyon.ui.redbumper.entities.RBGetVehicleInfoByVin_AllTrims
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.lang.Class.classForName(Native Method)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.lang.Class.forName(Class.java:235)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:2590)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1846)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:826)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2066)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:929)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2285)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2240)
03-19 15:39:02.549: E/AndroidRuntime(27084): at android.os.Parcel.readSerializable(Parcel.java:1945)
03-19 15:39:02.549: E/AndroidRuntime(27084): ... 15 more
03-19 15:39:02.549: E/AndroidRuntime(27084): Caused by: java.lang.NoClassDefFoundError: com.halcyon.ui.redbumper.entities.RBGetVehicleInfoByVin_AllTrims
03-19 15:39:02.549: E/AndroidRuntime(27084): ... 25 more
03-19 15:39:02.549: E/AndroidRuntime(27084): Caused by: java.lang.ClassNotFoundException: com.halcyon.ui.redbumper.entities.RBGetVehicleInfoByVin_AllTrims in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.adplotmanagement-1.apk]
03-19 15:39:02.549: E/AndroidRuntime(27084): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
03-19 15:39:02.549: E/AndroidRuntime(27084): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
03-19 15:39:02.549: E/AndroidRuntime(27084): ... 25 more
错过了再补充一点,我有两个功能相同的应用程序,每个应用程序都有相同的类GetVehicleInfo_AllTrims
,它是一个 pojo 类。当我在前台运行一个应用程序时,位于后台的另一个应用程序因上述错误而崩溃。