Building 60 APKs in 15 minutes

What’s an APK?

An APK stands for Android Package Kit. It is the file containing an app on android. We publish APK files to the market and customers download on their phones and tablets to install our app.

Why 60 APKs?

We have 15 apps now, each with their own APK –

  1. Kids Shapes
  2. Kindergarten Math
  3. Kindergarten Math Lite
  4. Kids Phonics
  5. Kids Phonics Lite
  6. Kindergarten Word Play
  7. Kindergarten Word Play Lite
  8. Kids Measurement Science
  9. Kids Measurement Science Lite
  10. First Grade Math
  11. First Grade Math Lite
  12. First Grade Word Play
  13. First Grade Word Play Lite
  14. Second Grade Math
  15. Second Grade Math Lite.

We publish the apps to 3 markets so far. For each market, we have to build its own APK. Most of the code is the same. The difference is in the market links that the app contains to review or buy the apps. For Amazon, the link from the app goes to amazon market place. For google, it goes to google play store, for nook – it goes to nook store.

We are planning to add another market – Nokia, for the Nokia X series of Android phones to be released next week. So, that’s a fourth market.

15 apps to be published to 4 markets – 15 X 4 – gives us 60 APKs.

How much time did it take?

I used to build each of the apks by hand. I was typically only releasing one project at a time, and three apks built using export wizards was not that big a deal. When adding the Nokia market, I am building all the apks for Nokia. Also, since there was some releases planned, I was also building half the apps for all the other markets. It would take a day to build all the apks by clicking buttons on a wizard. Not only that, the process was error prone – did I change that directory name, or, did I accidentally export the amazon build into the nokia directory.

How did it get down to 15 minutes?

Android supports ant builds. It is not the newest or greatest means of doing builds, but, it works. Put the android provided build.xml in the project directory. Write a few customizations to switch the market links in custom_rules.xml. The hooks are already in the provided bulid file. Put the properties to sign the apk in a property file. And you can build the project using the command line.

I also wrote a custom master build – again using ant – that invokes each of the builds for each of the markets. It moves the apk over to the release directory to the correct market as well. Only step left is for me to smoke test the final build and upload it to the market.

It is easier to add new markets too. Add a new definition for the market links. Add the new market to the master build. Sit back, drink tea, and write this blog, while the build runs.

Other Options

We use the build to switch markets. Mike had suggested that we should use libraries instead. The main project would be a library, and the final project will import the library and customize for the market. That would result in 60 projects! It is too much for me to track, but, it might work better for a bigger team to have the project divided into libraries.

Conor wanted me to use Gradle instead of Ant. I looked at doing that, but, the android directory structure was different for Gradle than what is created by the android eclipse plugin. This late in the game, it is too much work to switch it. But, I would look at it for future projects.

Lessons Learnt

What a time-saver! I should’ve done it a long time ago. 2 days to write and test the build – saves a day over and over again.

Next, I should automate the smoke testing…. hmmm. Any suggestions?

References

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s