0

我试图让我的 Android 应用程序与我的 GWT WebProject (GWT 2.5.1) 进行通信......通常我已经从代码的角度确定了它,但我一直遇到代码导入问题......

最初,当我尝试使用 SyncProxy 从 android 项目实例化它们时,我会在 RPCService 和 RPCServiceAsync 类上得到一个 NoClassDefFoundError ,并且它们是在 web 项目中定义的......即使移动项目依赖于构建路径中的 web 项目它没有将 Web 项目代码导出到移动 apk 中...我认为这可能是因为 GWT 编译实际上将事物转换为 javascript 而不是构建 jar 但不确定...

我继续将 RPCService 和 RPCServiceAsync 文件移动到 andoird 项目,但将 RPCServiceImpl 保留在 web 项目中并切换了依赖项(即 web 项目依赖于 android )......我现在不再收到 NoClassDefFoundError 而是同步代理失败说它在类路径中找不到策略文件...那是因为策略文件位于 Web 项目的 WAR 目录中...

在我看来,我错误地拆分了我的项目,我想知道最好的方法是什么?我怎样才能让 GWT 应用程序导出 rpc 策略文件和/或其 java 类?

谢谢

4

2 回答 2

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.

于 2013-12-03T08:41:31.193 回答
0

我也被这个错过了,但现在经过两天的调试。我对此比较清楚。

SyncProxy 需要您拥有 GWT 项目(服务器端)的全部代码。为此,您只需创建一个将 SyncProxy 触发到其中的附加类。在这个类中,你应该导入所有需要的类和函数,这就是你需要服务器代码的原因。

并且您必须将在服务器端生成的“*.gwt.rpc”文件放到该项目的类路径中。

我认为这足以让您触发 SyncProxy。

于 2015-04-02T08:49:09.563 回答