Rebuilding Android modules for Titanium 6.x

I originally posted a version of this on my own blog, but was encouraged by the TiSlack crew to cross post it here.

Appcelerator recently released a major SDK update which included breaking changes for Android modules (among other breaking changes). All Android modules had to be recompiled with the newest SDK tooling in order to use them with the 6.x app SDK.

Our app uses a half-dozen community-contributed modules. Some of those are now unsupported by their original authors. Plus, being a good open-source citizen, we knew we should help where we could to update the others.

If you haven’t compiled Android modules yet, this is not the guide for you. You’ll need a working Java, Titanium, ant environment. See the Appcelerator guides for that info. Assuming that’s all set up, the process is actually pretty simple.

Update the module’s manifest file:

  • Bump apiversion from 2 to 3
  • Remove “armeabi” from the architectures list
  • Update the minsdk to 6.0.0.GA (or higher)
  • Bump the major version of the module. (Breaking changes should increment the first number. For example, going from 1.0.0 to 2.0.0.)

Update the module’s build.properties file:

  • Update titanium.platform to point to the location of the 6.0.x SDK on your system
  • Make sure that both the API and Google API levels are set to 23 (higher probably works, though I didn’t test it)
  • Use an NDK version of android-ndk-r10e or newer

Code changes:

You will need to remove all references to TiContext from the source code (the module’s .java files). The only references I saw were in overloaded constructors. In each of those cases, I simply deleted the constructors and the associated import statements.

Depending on the age of the codebase you’re working with, you might also have to update a few of the import statements. I found these changes were needed in some modules:

  • org.appcelerator.titanium.util.TiConfig should now be org.appcelerator.kroll.common.TiConfig
  • org.appcelerator.titanium.util.Log should now be org.appcelerator.kroll.common.Log

You might find it helpful to look at some of the modules that Appcelerator updated for this release to see the sorts of changes they made. For example:

None of the modules we’re using require the Google Play Services APIs. If yours do, you might run into the issues noted on TIMOB-23502. Likewise, we never had issues with the multiple README files mentioned in the comments on that ticket. YMMV.

Check for new versions, first, though:

Since the Titanium 6.x SDK has been out for a while now, many modules have been updated. For unmaintained projects, you might not find an updated zip on the main repo page. Check any outstanding pull requests for a community-contributed update. You might get lucky and find the PR includes a new zip file.

If there’s nothing there, you could check the project’s forks to see if someone made an update without submitting a pull request back to the original project. At the GitHub project’s page, click the number next to Forks in the top right. This will show you a graph of all the forks of the project. Start by checking the forks that branched the most recently from master and has the newest contributions.

Finally, if you need more help or get stuck, ask on TiSlack. Happy module-updating!