4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

The Android build system compiles app resources and source code, and packages them into

APKs or Android App Bundles that you can test, deploy, sign, and distribute. Android Studio
uses Gradle, an advanced build toolkit, to automate and manage the build process, while
allowing you to define flexible custom build configurations. Each build configuration can
define its own set of code and resources, while reusing the parts common to all versions of
your app. The Android plugin for Gradle works with the build toolkit to provide processes
and configurable settings that are specific to building and testing Android applications.

Gradle and the Android plugin run independent of Android Studio. This means that you can
build your Android apps from within Android Studio, the command line on your machine, or
on machines where Android Studio is not installed (such as continuous integration servers). If
you are not using Android Studio, you can learn how to build and run your app from the
command line. The output of the build is the same whether you are building a project from
the command line, on a remote machine, or using Android Studio.

Note: Because Gradle and the Android plugin run independently from Android Studio, you
need to update the build tools separately. Read the release notes to learn how to update
Gradle and the Android plugin.

The flexibility of the Android build system enables you to perform custom build
configurations without modifying your app's core source files. This section helps you
understand how the Android build system works, and how it can help you customize and
automate multiple build configurations. If you simply want to learn more about deploying
your app, see Building and Running from Android Studio. To start creating custom build
configurations right away using Android Studio, see Configuring Build Variants.

The build process

The build process involves many tools and processes that convert your project into an
Android Application Package (APK) or Android App Bundle (AAB). The build process is
very flexible, so it's useful to understand some of what is happening under the hood.
Figure 1. The build process of a typical Android app module.

The build process for a typical Android app module, as shown in figure 1, follows these
general steps:

1. The compilers convert your source code into DEX (Dalvik Executable) files, which
include the bytecode that runs on Android devices, and everything else into compiled
resources.
2. The packager combines the DEX files and compiled resources into an APK or AAB,
depending on the chosen build target. Before your app can be installed onto an
Android device or distributed to a store, such as Google Play, the APK or AAB must
be signed.
3. The packager signs your APK or AAB using either the debug or release keystore:
a. If you are building a debug version of your app, that is, an app you intend only
for testing and profiling, the packager signs your app with the debug keystore.
Android Studio automatically configures new projects with a debug keystore.
b. If you are building a release version of your app that you intend to release
externally, the packager signs your app with the release keystore that you need
to configure. To create a release keystore, read about signing your app in
Android Studio.
4. Before generating your final APK, the packager uses the zipalign tool to optimize
your app to use less memory when running on a device.

At the end of the build process, you have either a debug or release APK or AAB of your app
that you can use to deploy, test, or release to external users.

You might also like