Android to gae restlet example doesn't work on the Android side

和自甴很熟 提交于 2019-12-23 05:30:26

问题


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]

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.

Any idea how to go from here?

Some notes:

  • I use restlet 2.1.4
  • I used curl to test the server side and it works great. Example: curl -i -X GET http://127.0.0.1:8888/contacts/123
  • To test Android against a local server, I use the following ip: 10.0.2.2

回答1:


Yes, found a solution.

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

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

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



来源:https://stackoverflow.com/questions/19593337/android-to-gae-restlet-example-doesnt-work-on-the-android-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!