I have a perfectly working GWT application. Now I am trying to use gwt-syncproxy
to create an Android client which can simply reuse the server side code.
So far everything was working perfectly. The only problem that I can find is when I start RPC to a method expecting an enum as a parameter.
The enum looks something like this:
import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
public enum ReferenceTable implements IsSerializable, Serializable
{
basetable, othertable;
ReferenceTable(){}
}
The error message I'm getting is:
com.google.gwt.user.client.rcp.IncompatibleRemoteServiceException: Invalid type signature for package.ReferenceTable
which suggests that it's a problem related to serialization.
I tried using different combinations of IsSerializable
and Serializable
and always cleaned the project before deploying. Both the GWT app and the Android app use the same code for the data types used for communication.
Does anyone have an idea how to solve this? If nothing else works, I could refrain from using enums, but I would prefer using them. Especially, since everything is working for the GWT server-client communication itself.
BTW: The error on the server side is:
Caused by: com.google.gwt.user.client.rpc.SerializationException: Invalid type signature for some.package.ReferenceTable
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.validateTypeVersions(ServerSerializationStreamReader.java:1116)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserialize(ServerSerializationStreamReader.java:610)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.readObject(ServerSerializationStreamReader.java:567)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader$ValueReader$8.readValue(ServerSerializationStreamReader.java:140)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserializeValue(ServerSerializationStreamReader.java:425)
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:312)
... 24 more
EDIT:
I created both a sample GWT app and a sample Android app, so people can actually try the code:
To deploy the app, just modify the build.properties
file and then run build.xml
as an ant script. In the MainActivity
of the Android app, modify the URL to point to the GWT app.