views:

82

answers:

3

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 NoSuchMethodException

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

+1  A: 

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.

Juri
A: 

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.

Doughy
A: 

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.

chief