I have a normal java app that sends the same object to the servlet with no problems, but when I attempt it in an android app using the same code it craps out on me at:
outputToServlet.writeObject(myobject)
Throwing the NoSuchMethodE开发者_如何学Pythonxception
I'm able to send a String object no problem via the Android app...
I've seen the "don't use serialization between architectures" answer, but I'd like to know why not?
Any ideas?
-chief
For your question "Don't use serialization between architectures"...
Basically because you couple things (client & server) too tightly. When you use serialization you have to have exactly the same objects on both sides which may become quite cumbersome soon. Instead try to use other protocols for communication. I've successfully used XML-RPC on Android for my client-server communication. Here's a nice, lightweight lib. I had just to modify some minor things and it worked perfectly.
My guess is that your class definition contains data types that are somehow not supported by writeObject in Android. Try limiting your class to only common data types like int, string, etc.. and see if it works.
Found the problem. I was using a non-native datatype in my class, a Key for the Google App Engine. Once removed, the exception wasn't thrown. Thanks Doughy! Also thank Juri for the info for my other question. Appreciate it.
精彩评论