Projects Overview: Modules
Projects Overview: Modules
A project in Android Studio contains everything that defines your workspace for
an app, from source code and assets, to test code and build configurations.
When you start a new project, Android Studio creates the necessary structure
for all your files and makes them visible in the Project window on the left side
of the IDE (click View > Tool Windows > Project). This page provides an
overview of the key components inside your project.
Modules
A module is a collection of source files and build settings that allow you to divide
your project into discrete units of functionality. Your project can have one or
many modules and one module may use another module as a dependency.
Each module can be independently built, tested, and debugged.
Additional modules are often useful when creating code libraries within your
own project or when you want to create different sets of code and resources for
different device types, such as phones and wearables, but keep all the files
scoped within the same project and share some code.
You can add a new module to your project by clicking File > New > New
Module.
Provides a container for your app's source code, resource files, and app level
settings such as the module-level build file and Android Manifest file. When you
create a new project, the default module name is "app".
Wear OS Module
Android TV Module
Glass Module
They each provide essential files and some code templates that are
appropriate for the corresponding app or device type.
For more information on adding a module, read Add a Module for a New
Device.
Feature module
Represents a modularized feature of your app that can take advantage of Play
Feature Delivery. For example, with feature modules, you can provide your users
with certain features of your app on-demand or as instant experiences
through Google Play Instant.
Library module
Provides a container for your reusable code, which you can use as a dependency
in other app modules or import into other projects. Structurally, a library
module is the same as an app module, but when built, it creates a code archive
file instead of an APK, so it can't be installed on a device.
Android Library: This type of library can contain all file types supported in an
Android project, including source code, resources, and manifest files. The build
result is an Android Archive (AAR) file that you can add as a dependency for your
Android app modules.
Java Library: This type of library can contain only Java source files. The build
result is an Java Archive (JAR) file that you can add as a dependency for your
Android app modules or other Java projects.
Provides a container for your Google Cloud backend code. This module has the
required code and dependencies for a Java App Engine backend that uses
simple HTTP, Cloud Endpoints, and Cloud Messaging to connect to your app.
You can develop your backend to provide cloud services your app needs.
Using Android Studio to develop your Google Cloud module lets you
manage app code and backend code in the same project. You can also
run and test your backend code locally, and use Android Studio to deploy
your Google Cloud module.
dependencies {
compile project(':my-library-module')
}
Project files
Within each Android app module, files are shown in the following groups:
manifests
Contains the AndroidManifest.xml file.
java
Contains the Java source code files, separated by package names, including
JUnit test code.
res
Contains all non-code resources, such as XML layouts, UI strings, and bitmap
images, divided into corresponding sub-directories. For more information about
all possible resource types, see Providing Resources.