Projects overview

A project in Android Studio contains everything that defines your workspace for an app, from source code and assets, to test lawmaking and build configurations. When you first a new project, Android Studio creates the necessary construction 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 within your project.

Modules

A module is a drove of source files and build settings that allow yous to split up your project into discrete units of functionality. Your project can accept one or many modules, and one module may use some other module as a dependency. You lot can independently build, test, and debug each module.

Additional modules are often useful when creating code libraries inside your own projection or when you want to create different sets of code and resources for dissimilar device types, such as phones and wearables, but keep all the files scoped inside the same project and share some code.

Add a new module to your projection by clicking File > New > New Module.

Android Studio offers a few distinct types of module:

Android app module
Provides a container for your app'due south source code, resource files, and app level settings such every bit the module-level build file and Android Manifest file. When you create a new project, the default module name is "app".

In the Create New Module window, Android Studio offers the following types of app modules:

  • Phone & Tablet Module
  • Wear Bone Module
  • Android TV Module
  • Glass Module

Each provides essential files and some code templates that are appropriate for the corresponding app or device type.

For more information on calculation a module, read Add together 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.

To learn more, read Add together support for Play Feature Commitment.

Library module
Provides a container for your reusable code, which you lot 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 exist installed on a device.

In the Create New Module window, Android Studio offers the following library modules:

  • Android Library: This blazon 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 tin can add as a dependency for your Android app modules.
  • Java Library: This type of library can contain only Java source files. The build issue is an Java Archive (JAR) file that you lot can add together as a dependency for your Android app modules or other Java projects.
Google Deject module
Provides a container for your Google Cloud backend lawmaking. This module has the required code and dependencies for a Java App Engine backend that uses simple HTTP, Cloud Endpoints, and Deject 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 lot manage app code and backend code in the same project. You lot can also run and test your backend lawmaking locally, and utilize Android Studio to deploy your Google Cloud module.

For more information on running and deploying a Google Cloud module, run into Running, Testing, and Deploying the Backend.

Some people as well refer to modules as sub-projects and that's okay, because Gradle also refers to modules as projects. For case, when you lot create a library module and want to add together information technology as a dependency to your Android app module, you must declare it every bit follows:

Smashing

dependencies {     implementation projection(':my-library-module') }                      

Kotlin

dependencies {     implementation(project(":my-library-module")) }                      

Project files

By default, Android Studio displays your projection files in the Android view. This view does not reflect the actual file hierarchy on disk, but is organized by modules and file types to simplify navigation between key source files of your project, hiding sure files or directories that are not usually used. Some of the structural changes compared to the structure on deejay include the following:

  • Shows all the project's build-related configuration files in a top-level Gradle Script group.
  • Shows all manifest files for each module in a module-level group (when you lot accept different manifest files for unlike product flavors and build types).
  • Shows all culling resource files in a single group, instead of in carve up folders per resource qualifier. For case, all density versions of your launcher icon are visible side-past-side.

Inside each Android app module, files are shown in the following groups:

manifests
Contains the AndroidManifest.xml file.
coffee
Contains the Java source code files, separated by package names, including JUnit examination code.
res
Contains all non-code resources, such every bit XML layouts, UI strings, and bitmap images, divided into corresponding sub-directories. For more information about all possible resource types, come across Providing Resources.

The Android projection view

To see the bodily file structure of the project including all files hidden from the Android view, select Projection from the dropdown at the top of the Projection window.

When yous select Projection view, you lot can see a lot more files and directories. The most important of which are the following:

module-proper noun/
build/
Contains build outputs.
libs/
Contains private libraries.
src/
Contains all code and resource files for the module in the following subdirectories:
androidTest/
Contains lawmaking for instrumentation tests that run on an Android device. For more information, see the Android Examination documentation.
main/
Contains the "main" sourceset files: the Android code and resources shared by all build variants (files for other build variants reside in sibling directories, such every bit src/debug/ for the debug build blazon).
AndroidManifest.xml
Describes the nature of the application and each of its components. For more than information, see the AndroidManifest.xml documentation.
java/
Contains Java code sources.
jni/
Contains native code using the Coffee Native Interface (JNI). For more information, see the Android NDK documentation.
gen/
Contains the Coffee files generated by Android Studio, such as your R.java file and interfaces created from AIDL files.
res/
Contains application resources, such every bit drawable files, layout files, and UI string. Run across Application Resources for more than data.
avails/
Contains file that should be compiled into an .apk file as-is. You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the AssetManager . For example, this is a good location for textures and game information.
examination/
Contains code for local tests that run on your host JVM.
build.gradle (module)
This defines the module-specific build configurations.
build.gradle (project)
This defines your build configuration that apply to all modules. This file is integral to the project, so you should maintain them in revision control with all other source lawmaking.

For information about other build files, see Configure Your Build.

Project structure settings

To change various settings for your Android Studio project, open the Project Structure dialog by clicking File > Project Structure. Information technology contains the following sections:

  • SDK Location: Sets the location of the JDK, Android SDK, and Android NDK that your project uses.
  • Project: Sets the version for Gradle and the Android plugin for Gradle, and the repository location name.
  • Modules: Allows you to edit module-specific build configurations, including the target and minimum SDK, the app signature, and library dependencies. Come across Modules, beneath.

Modules

The Modules settings section lets y'all change configuration options for each of your project's modules. Each module's settings folio is divided into the following tabs:

  • Properties: Specifies the versions of the SDK and build tools to use to compile the module.
  • Signing: Specifies the certificate to use to sign your app.
  • Flavors: Lets you create multiple build flavors, where each flavor specifies a set of configuration settings, such as the module's minimum and target SDK version, and the version code and version proper noun. For example, you might define one flavour that has a minimum SDK of fifteen and a target SDK of 21, and another season that has a minimum SDK of xix and a target SDK of 23.
  • Build Types: Lets you create and alter build configurations, equally described in Configuring Gradle Builds. By default, every module has debug and release build types, just yous can ascertain more equally needed.
  • Dependencies: Lists the library, file, and module dependencies for this module. You tin add together, modify, and delete dependencies from this pane. For more data nearly module dependencies, run across Configuring Gradle Builds.