Android的到GAE的Restlet例子在Android端不起作用不起作用、例子、Android、GAE

2023-09-07 02:51:30 作者:听风看月

我试图运行的Restlet的第一个应用实例 - 机器人到GAE - 但返回的值常是空,显示了Android的LogCat中警告:无法找到此重新presentation转换器:应用程序/ JSON,UTF-8]

I'm trying to run restlet's first application example - android to gae - but the value returned is alway null, showing a warning in Android's LogCat: Unable to find a converter for this representation : [application/json,UTF-8]

具体code返回null是这一行:

The specific code that returns null is this line:

Contact contact = resource.retrieve();

我的假设,这是一个转换的问题。如果是这样,我很惊讶,这只是一个警告。

My Assumption that it's a conversion issue. If so, i'm surprised it's just a warning.

不知道如何走?

一些注意事项:

我用的Restlet 2.1.4 我用卷曲来测试服务器端和它的伟大工程。例如:卷曲-i -X​​ GET http://127.0.0.1:8888/contacts/123 要测试的Andr​​oid针对本地服务器,我使用下面的IP:10.0.2.2

推荐答案

是的,找到了解决办法。

Yes, found a solution.

我只需要注册一个转换器 - 杰克逊特别变频器。发现在下述溶液中SO回答: http://stackoverflow.com/a/5205993/435605

I just needed to register a converter - Specifically Jackson converter. Found the solution in the following SO answer: http://stackoverflow.com/a/5205993/435605

Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());

我Android的应用程序类做了,因为它是一个全球性的注册,注册

The registration I did in Android's application class as it's a global registration.