By Michael Burton

To avoid crashes, use Android lint. When dealing with backward compatibility, it’s very easy to accidentally use some APIs that are available on your current API version, but weren’t available a few years ago on older versions of Android. If you’re not paying attention and do this, everything will seem to work fine on your latest-and-greatest phone, but your users will see crashes on their older phones.

A great tool is available to help you find these sorts of situations before they happen. It’s called Android lint.

If you are familiar with the lint tool on other programming platforms, Android lint is very similar. Android lint examines the source code for your project and finds anything that looks suspicious and could possibly be a bug. Not all these warnings may, in fact, turn out to be bugs, but it’s important to go through each one and make sure you know whether they are or aren’t.

The reason that Android lint is so useful when working with backward compatibility is that it automatically flags any use of older APIs that haven’t been wrapped in build version checks.

To run Android lint, open a file in the Tasks project and then choose Analyze→Inspect Code. Click Module ‘Tasks’ as shown and click OK.


After Android lint has finished running, you see a report similar to this one.


This report gives you a list of warnings that may or may not be bugs in your app. You click each warning to view a description of it. If it’s a bug, then you should fix it. If it’s not in this particular case, you are given the option to suppress the warning. By suppressing the warning, you indicate to the lint tool that you acknowledge the warning, you have checked it, and you know it’s not an error.

Android lint can be a very powerful tool to find potential problems with your code before you release it. Make sure you run it frequently and keep your codebase clean and lint free!