Chapter 9. Build Tools

When building apps, at some point it will be necessary to compile your code, and package it into a deployable artifact. This chapter outlines the tools used to do this.

The automated build tools can also package Android applications. There is support for a variety of tools, including Ant, Maven, and most recently Gradle. It is beyond the scope of this book to go into a lot of detail about using these tools, but let’s go through some basic concepts to get you started.

Compiling Your Code

When writing computer applications, it is necessary to translate the computer language you are using (in our case Java) to a different computer language that the computer can understand (in this case, Dalvik Compatible executables, or DEX files). This process is called compiling. You will need to do this during the coding process in order to validate your code, and also when you are packaging your code for release.

If you are running the most current version of Java (or anything newer than version 1.6), it is necessary to set the compliance level of your project in order to get Android to build correctly. To do this:

  1. Right-click on your Android project.

  2. Select PropertiesJava Compiler.

  3. Check the “Enable project specific settings” option.

  4. Choose either 1.5 or 1.6 from “Compiler compliance settings.”

The code will then be compiled if you are using Eclipse and have the “Build Automatically” setting selected. To select it, make sure ProjectBuild Automatically is checked.

Packaging an ...

Get Android Developer Tools Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.