May 2013

Android SDK Tools 22.0.1 Considered Harmful

After finishing up some work on an iOS app today, it was time to go make equivalent changes to the Android port of that app. "I'll just update my Android SDK before I get to work," I said (to myself). I opened the Android SDK Manager and let it update these SDK packages to these versions:

  • Android SDK Tools: 22.0.1
  • Android SDK Platform-tools: 17
  • Android SDK Build-tools: 17

Then I let Eclipse update the ADT. Then I got to work. I opened my Android app project and tried to run it. I found I couldn't make a working debug build or a release build, nor could I create a signed APK to install on a device.

After a few hours of hair pulling, I got everything working. Here is what I learned. I hope it helps someone.

UIColor Category for Specifying Packed RGB Values

iOS's UIColor class makes it pretty easy to specify a color using red, green, blue (RGB) and alpha components:

 // set pale yellow color
 label.textColor = [UIColor colorWithRed:1.0
                                   green:1.0
                                    blue:0.5
                                   alpha:1.0];

However, as with many Cocoa API's, it's pretty verbose. Web developers would specify that color using the hexcode shorthand #ffff80, and many graphics editing tools would generate a hexcode value like that rather than values in the range 0.0–1.0.

So I made a simple category on UIColor that lets one write stuff like this:

#include "UIColor+KDJPackedRGB.h"

// ...

// set pale yellow color
label.textColor = [UIColor colorWithRGB24:0xffff80];

See https://gist.github.com/kristopherjohnson/5606209