The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.

Lint and the Support Annotations

As C/C++ developers are well aware, lint is not merely something that collects in pockets and belly buttons.

lint is a long-standing C/C++ utility that points out issues in a code base that are not errors or warnings, but are still indicative of a likely flaw in the code. After all, what might be legal from a syntax standpoint may still be a bug when used.

Android Studio and the Android Plugin for Gradle have their own equivalent Lint tool, for reporting similar sorts of issues with an Android project’s Java code, resources, and manifest. You can also get Lint reports from the command line, such as via the Android Gradle Plugin, perhaps as part of integrating your builds into a continuous integration server.

To help Lint catch problems stemming from your own code, Google has released the support-annotations library, to help catch things like passing a widget ID, instead of a layout ID, into setContentView(). You can also use these annotations to help those using your code – whether in the same project or in consumers of a library that you publish – make sure that they do not make similar mistakes.

This chapter will explore how you use Lint to detect problems and how you can add annotations to your code to help Lint catch even more problems.


Understanding this chapter requires that you have read the core chapters of this book.

What It Is

The preview of this section was eaten by a grue.

When It Runs

The preview of this section was the victim of a MITM ('Martian in the middle') attack.

What to Fix

The preview of this section is being chased by zombies.

What to Configure

The preview of this section is in the process of being translated from its native Klingon.

Support Annotations

The preview of this section is [REDACTED].