Android Project Folder Structure

In android studio, a project contains everything from source code and assets to code testing and configuration definition. Whenever any project is created, Android studio creates basic folder structures that can be used

  • to write code to do the things dynamically.
  • to write code to show the UI.
  • to store images, audio, videos or other media files.
  • to change the UI based on the device configurations.
  • to test the functionality of application.
  • to build the application and store application apk file.

 

You can see created project in different modes. These modes are available at left-top corner.

Whenever a new project is created, it’s default view is shown in Android Mode. Only app module related things can be seen in Android mode. Since we are going to see the folder structure, we need to change this mode to Project.

It will show maximum details about the project. You simply have to select Project mode from the menu.


The following structure would appear in the newly created Project mode.

In Project Mode, the Folder Structure would look below in the newly created project.

 

Different folders and files are as below –

HelloWorld :- This is project root directory.

.gradle :- You can find all the parameters and files used by steps to build the project in this folder. You can delete these files if you want. These files will be created when the project is rebuilt.

.idea :- Android Studio stores project specific meta-data in this folder. It contains a set of configuration files. For a certain functional area, each file contains configuration data. The file name explains the area of function itself. For example, compiler.xml, encodings.xml, modules.xml file etc.

app :- This is the actual project folder in which project code is saved. You write code here, create user interface, store assets, etc. We shall soon discuss in detail this section.

build :- This directory contains related information. When building the project, data is generated.

gradle :- You'd notice the folder in this wrapper. If your project distributes the wrapper, everyone can work on the project without the Gradle installed. Another benefit is that other users use the same Gradle version that is built to work correctly.

.gitignore :- All files that we want to exclude from the version control system are included in this folder.

buld.gradle :- This is a top-level build file where we add configuration options common to all sub-projects/modules. This is different from app/build.gradle file.

gradle.properties :- You can configure project - wide Gradle configuration. For example, Gradle daemon’s maximum heap size etc.

gradlew :- This file is related to gradle. It is created once and updated to update a new feature or plugin.

gradlew.bat :- This file is related to gradle. The new functionality or plugin that needs updated gradle version is created and updated once.

HelloWorld.iml :- This is a module file created by IntelliJ IDEA, an IDE used to develop Java applications. It saves development module information which can be a component Java, Plugin, Android or Maven ; it saves module paths, dependencies and other adjustments.

local.properties :- It includes local configuration specific information. For example, path to SDK etc. It should not be checked in the version control system because it contains local information.

settings.gradle :- This file handles project, module and other kinds of names and settings,

External Libraries :- This is not actually a folder but a place where referenced libraries are shown.

app/src :- It contains all the code and resource files required in the app module (images, audio, video, etc). It has sub folders too. We will discuss, in detail, about this later.

app/app.iml :- IML is a module file created by IntelliJ IDEA, an IDE used to develop Java applications. This stores development module information that may be a Java plugin, Android, or Maven component and saves the paths, dependencies, and other settings for modules.

app/proguard-rules.pro :- Here are customized rules for ProGuard. ProGuard detects and deletes from your packaged app, including code libraries, unused classes, fields, procedures and attributes.

It also optimises the byte code, removed unused code instructions, and obfuscates the remaining classes, fields, and methods with short names.

The falsified code makes the APK extremely valuable and difficult to reverse engineer, especially when we have information on payments.

The current android code and resource files in this folder. Below image clearly depicts the folder structure.

 

The actual Android code and resource files are in this folder. Below image clearly depicts the folder structure.


This folder contains following files and sub-folders.

java : This folder contains java code source.

res : It includes app resources such as drawable files, layout files, UI string, size, colors, etc. This folder also has sub-folders as below. Below are the sub-folder that resides inside res folder –

res/drawable : This folder contains drawable xml files and images.

res/mipmap : This folder contains launcher icon.

res/values : We store various values used in the application in the folder values. The application, for example, uses various colours, dimensions, strings, styles. Basically they are used to delete a hard - coded value. This also helps in resource localisation and internationalisation. This directory contains a separate file for each value type. They are –

res/values/colors.xml : This file contains different colors used in the application.
res/values/dimens.xml : This file has various dimensions used in the application.
res/values/strings.xml : This file has various strings used in the application.
res/values/styles.xm l: This file contains different styles used in the application.

Other folder in res folder –

res/raw : This folder can be created in res folder and you can store audio, video etc.

AndroidManifest.xml : In every android application, you must have this file. It describes the nature and the components of the application. It also includes the name of the application java package that serves as the application's unique identification. It also includes the minimum android API level required for an application.