Thursday, October 31, 2013

Sync framework for Android

Background: I work for Clio, we make a web-based practice management software for lawyers (and we are hiring!). We recently launched an iPhone app which I was a part of (more about the experience I had with iOS development and the project in general, here is the blog post). And we recently started to work on Android app for that. I am new to Android development, so for the past few weeks, it is all about learning Android development and researching things. One of things I am researching on right now is deciding what framework we should use for syncing.

Clio is a data-heavy app. For the iOS app, we use RestKit and CoreData as a persistent storage system. I am looking for an equivalent of RestKit in Android. I have few acceptance criteria for this. It should work well with Clio's REST API, and should be flexible enough to work with the nested attributes and polymorphic associations. And it should support JSON, and have a good community, well used, well tested by apps of similar complexity to Clio.

This post is a summary of my findings today and a conclusion I am about to make. If you have any suggestions or comment, you are more than welcome :)

I am new to Android, so if you have experience with this field, please share your experience with me. I would love to talk. Find me on Twitter at @naoyamakino.

it looks like yet another HTTP client for Android. Nothing much beyond that.

“Spring's RestTemplate is a robust, popular Java-based REST client. The Spring for Android RestTemplate Module provides a version of RestTemplate that works in an Android environment.”

“RestTemplate's behavior is customized by providing callback methods and configuring the HttpMessageConverter used to marshal objects into the HTTP request body and to unmarshal any response back into an object.”

HTTP Client: used default ClientHttpRequestFactory,  when you create a new RestTemplate instance. (the standard J2SE facilities)
Google recommends to use the J2SE facilities on Gingerbread (Version 2.3) and newer, while previous versions should use the HttpComponents HttpClient.
RestTemplate supports sending and receiving data encoded with gzip compression.
Libraries that are used for JSON mapping: Jackson JSON Processor, Jackson 2.x, and Google Gson.
RestTemplate provides higher level methods that correspond to each of the six main HTTP methods. These methods make it easy to invoke many RESTful services and enforce REST best practices. For example, the method getForObject() will perform a GET, convert the HTTP response into an object type of your choice and return that object. The method postForLocation() will do a POST, converting the given object into a HTTP request and return the response HTTP Location header where the newly created object can be found.
Objects passed to and returned from the methods getForObject(), getForEntity(), postForLocation(), postForObject() and put() are converted to HTTP requests and from HTTP responses by HttpMessageConverter instances.
You can also write your own converter and register it via the messageConverters property (customizable)
RoboSpice is a modular android library that makes writing asynchronous long running tasks easy. It is specialized in network requests, supports caching and offers REST requests out-of-the box using extension modules.
- executes network requests asynchronously (in a background AndroidService)

RestTemplate from Spring seems to accommodate most of my needs. it handles HTPP requets/response, and do a mapping from JSON to Java objects and vice versa. It looks pretty cool. I haven't tried it yet, but I like it so far from the readings I've done. If you have any suggestions or things I might want to know, please let me know.

Journey with Android development continues..


  1. Retrofit is likely to be robust and mature, if it's the right solution for you, as it's another of the Jake Wharton group of OSS projects released by Square

    1. thanks, I will definitely check that up this weekend. I came across that library but I didn't had a chance to look deep into that one yet. thanks for the suggestion. I will look into this more deeply.

  2. I am also new to Android, so if you have experience with this field, please share your experience with me. I would love to talk Or to listen to. The best paper writing service is a unique chance to boost your poor writings!

  3. When you're tired, you want to relax after a stressful working hours, you need to have time to take care of the kids active.
    Please visit our website and play exciting flash games.
    Thanks you for sharing!
    Friv 4