2013-03-19 55 views
1

我是Android開發人員,我試圖使用BundleSerializable對象發送給另一個Activity。但是,我得到以下 - Parcelable encountered ClassNotFoundException reading a Serializable object作爲錯誤。ClassNotFoundException同時傳遞可串行化

這是什麼原因,我該如何解決?

下面是代碼片斷:

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.a[email protected]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類。當我在前臺運行一個應用程序時,居住在後臺的另一個應用程序崩潰,出現上述錯誤。

+0

在這裏發佈你的代碼片段+完整的錯誤堆棧跟蹤。 – SudoRahul 2013-03-19 14:31:13

+0

你的班級'RBGetVehicleInfoByVin_AllTrims'也是可序列化的嗎? – Nachi 2013-03-19 14:42:26

+0

是該類是一個可序列化的類,我爲該類創建了對象(trimsObj)並將其發送給另一個活動。 – sathish 2013-03-19 14:43:45

回答

0
java.lang.ClassNotFoundException: com.halcyon.ui.redbumper.entities.RBGetVehicleInfoByVin_AllTrims 

這樣做有什麼

其原因的原因是例外,該類com.halcyon.ui.redbumper.entities.RBGetVehicleInfoByVin_AllTrims沒有被發現。

我該如何解決?

使該類在應用程序的CLASSPATH上可用。

+0

您好EJP,您能否提供一些示例代碼或鏈接,說明如何將此類添加到應用程序的CLASSPATH – sathish 2013-03-20 05:59:27

1

您好找到問題的根本原因並解決它。

在兩個應用程序中,我們使用相同的BroadCastReceivers及其意向過濾器。由於這個問題,運行時無法爲應用找到合適的接收器。

我修改了兩個應用程序的意圖過濾器不同,現在它工作正常。