Friday, February 4, 2011

Google Voice, Android, JSON

I ended up looking at a Google Code Project providing an API for Google Voice recently when I was asked to add it to a Maven repository.
I wrote up some suggestions to improve the project:
  1. Add a build (Ant or Maven, etc), only Eclipse project files at the moment
  2. Add tags, where is the 1.6 release source files?
  3. Replace the json library using an unconventional package name (gvjava.org.json instead of org.json)
  4. Add unit tests (such as testing the SMSParser), there is only a functional test
I reviewed the libraries used in the project (dom4j, jaxen, jtidy, json), found versions available in Maven central to use, and offered to help create a Maven pom and get the project into Maven central.
After emailing these thoughts to the project owner, I was surprised to hear I would be added as a committer on the project.

Even more surprising was my research into the json library, which is a copy of the json.org library with a different package.
Apparently the package name was changed to avoid conflicting with the Android json library which uses the same package and class names, but different sources. The Android version is missing constructors and methods in some of the classes, but also has more methods in others (JSONTokener and especially JSONStringer).

But the shocking part is that the latest Android artifacts in Maven central (after 2.1_r1) depend on a version of the json.org library (org.json:json:20080701), which is just wrong. These are not the right classes to compile against for Android. And frustrated Android developers consider the json.org library "broken". It would make more sense to use an android-json library, but I don't see it happening at the moment.
Instead of using the Maven central artifacts, anyone developing in Maven and using the Android json library apparently needs to use the SDK deployer (only way to get the original Android jar into a Maven repo). Or use a different json library (or a different class package, as done in this case).

No comments:

Post a Comment