我正在尝试将对象从服务器应用程序发送到 android 客户端。所有的类都在同一个包中,并且在 Eclipse 的 src 文件夹中,包括导致 ClassNotFoundException: CardGame 的类。我是android新手,对java还很陌生,并且已经坚持了几天,所以我想知道是否有人能够帮助我找出问题所在......
这是导致问题的代码...
CardGame game = (CardGame) in.readObject();
这是堆栈跟踪...
04-21 19:21:35.608: W/System.err(482): java.lang.ClassNotFoundException: CardGame
04-21 19:21:35.618: W/System.err(482): at java.lang.Class.classForName(Native Method)
04-21 19:21:35.618: W/System.err(482): at java.lang.Class.forName(Class.java:235)
04-21 19:21:35.618: W/System.err(482): at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:2590)
04-21 19:21:35.618: W/System.err(482): at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1846)
04-21 19:21:35.618: W/System.err(482): at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:826)
04-21 19:21:35.618: W/System.err(482): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2066)
04-21 19:21:35.618: W/System.err(482): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:929)
04-21 19:21:35.628: W/System.err(482): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2285)
04-21 19:21:35.628: W/System.err(482): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2240)
04-21 19:21:35.628: W/System.err(482): at com.client.activity.play.init(play.java:107)
04-21 19:21:35.628: W/System.err(482): at com.client.activity.play.onCreate(play.java:54)
04-21 19:21:35.628: W/System.err(482): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-21 19:21:35.628: W/System.err(482): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-21 19:21:35.628: W/System.err(482): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-21 19:21:35.628: W/System.err(482): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-21 19:21:35.628: W/System.err(482): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-21 19:21:35.638: W/System.err(482): at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 19:21:35.638: W/System.err(482): at android.os.Looper.loop(Looper.java:123)
04-21 19:21:35.638: W/System.err(482): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 19:21:35.638: W/System.err(482): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 19:21:35.638: W/System.err(482): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 19:21:35.638: W/System.err(482): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 19:21:35.638: W/System.err(482): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 19:21:35.648: W/System.err(482): at dalvik.system.NativeStart.main(Native Method)
04-21 19:21:35.648: W/System.err(482): Caused by: java.lang.NoClassDefFoundError: CardGame
04-21 19:21:35.648: W/System.err(482): ... 24 more
04-21 19:21:35.658: W/System.err(482): Caused by: java.lang.ClassNotFoundException: CardGame in loader dalvik.system.PathClassLoader[/data/app/com.client.activity-1.apk]
04-21 19:21:35.658: W/System.err(482): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-21 19:21:35.668: W/System.err(482): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-21 19:21:35.668: W/System.err(482): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-21 19:21:35.668: W/System.err(482): ... 24 more
谢谢!