0

Im trying to get my Android app to communicate with my GWT WebProject (GWT 2.5.1)... generally i have it nailed down from a code perspective but i keep having code import problems...

Initially I would get a NoClassDefFoundError on the RPCService and RPCServiceAsync classes when trying to instantiate them from the android project using SyncProxy and they were being defined in the web project... even though the mobile project depended on the web project in build-path it was not exporting the web project code into the mobile apk... i figured this might be because the GWT compile actually converts things to javascript and not build a jar but not sure...

i proceeded to move the RPCService and RPCServiceAsync files to the andoird project but kept the RPCServiceImpl in the web project and switched the dependency (i.e. web project depends on android one)... i now no longer get the NoClassDefFoundError but instead the syncproxy is failing saying it cannot find the policy file in the classpath... that is because the policy file resides in the WAR directory of the web project...

it seems to me i am splitting my projects incorrectly and i wonder what is the best way to do it? how can i greate a GWT application that will export the rpc policy files and/or its java classes?

thx

2 Answers2

0

First, your initial setup was correct. It is better to have the service interfaces defined in the web app, and have your Android app draw from there. I'm not sure what IDE you're using, but in Eclipse, the feature you want to use in the Build Path dialog is called Link Source. Using this, you can point a build path directly to the web app's service interfaces in a way that they will be compiled with (not against) the Android app.

As a brief reference, take a look at the Setup in Eclipse section of the Android wiki in the SyncProxy project: https://code.google.com/p/gwt-syncproxy/wiki/Android. Also check out the Common Issues wiki. https://code.google.com/p/gwt-syncproxy/wiki/CommonIssues

As a point to note, the way it ultimately functions is not that the web app exports the code to the Android project. It is actually that the Android project will import the code into it's own source hierarchy from the GWT app source path.

With regards to the second error you received, the "lost" policy file, try running a GWT compile on your project and make sure your appengine-web.xml file, if using GAE as your service backend, has been modified as defined in the wiki (I just made a few updates).

Lastly, you may run into a one more error. Since you are using GWT 2.5.1, you may hit a serialization issue if you aren't running with the most up-to-date version of the SPALibrary. I'm going through the feedback on the tests for that now, and should have that file available for download within a few hours on the site. Please make sure to use 0.4.1 Android library if running against a GWT 2.5.1 ServiceImpl.

JCricket
  • 1,318
  • 2
  • 17
  • 34
  • As a point of update regarding the "cannot find the policy file" error, SyncProxy has been updated to resolve many of those specific issues as of version 0.5. The newest version has a few more algorithms to find the policy files as needed. – JCricket Jan 11 '15 at 04:44
0

I was missed up by this also, but now after tow days debugging. I am a bit more clear about it.

the SyncProxy needs you have the entire code of the GWT project(server side). And to do so, you just create one additional class which fire the SyncProxy into it. In this class you should import all needed classes and functions, that why you need server code.

and you must put the "*.gwt.rpc" file, which is generated in server side to this project's class path.

I think this is enough for you fire the SyncProxy.

Jerry Z.
  • 2,031
  • 3
  • 22
  • 28