Yesterday I released Rainy Days to celebrate passing the 400k downloads. Soon after, my celebration was partycrashed when a few users reported that Rainy Days wouldn’t open on their phone. First I was clueless, especially because I either couldn’t reach those users or couldn’t get a logcat from them showing me the error. The only thing I had to debug was their Android OS version and screen size basically. So I fired up some emulators and tested various configuration again, this is something I do before every release in fact. I couldn’t reproduce the bug.

Then I got one other email. Again, a user on 1.5 which couldn’t launch the app. So this time I took the released apk, put it on the emulator, and sure enough: it crashed on open. Actually it crashed with a verify error, meaning that a class is referencing methods that don’t exist on that platform.

When it runs fine from Eclipse on 1.5, but the released version doesn’t it, what is the difference? The released version was run through Proguard to obfuscate the code. But Proguard does not only obfuscate, but also optimize your code and it does a pretty good job at it.

Unfortunately it had this time inlined the class I use for compatiblity code which caused the verify error. The code I took great care to separate out to make sure it wouldn’t be called on older platforms was now inlined in my main activity. Auch.

So the lessons learned are these: be aware of optimization and test the release apk on the emulator. Proguard is a powerful tool and with great power comes great responsibility :)