Structure of the project - First look

by Oleg Skidan on 01st March 2018

Let's talk about the main components of each application. Let's pay attention to the left side of our project. We will see the tree of our project.

Project Structure

If you do not see this tree, then press ALT + 1 (or the Project button). By default, our structure consists of 2 elements:

  1. The app folder is the folder with the code and the main application resources.
  2. Gradle scripts are scripts that help to manipulate our project (collect it, clean the project of unnecessary files, manage finished assemblies, and so on).

    Gradle is an open-source build automation system that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the XML form used by Apache Maven for declaring the project configuration. Gradle uses a directed acyclic graph ("DAG") to determine the order in which tasks can be run.

    We will get acquainted with this system of assembly a bit later.

It should be noted that for some people this structure of the project may seem unusual. In fact, the kind of tree that we see shows a not quite real picture of the folders and files of your project. Those who are used to the structure of projects on Java can choose a different kind of structure (such as you are more comfortable with), as shown in the figure below. However, I recommend using the kind of Android folders, as shown in the first picture.

Android Folders

The first step is to get acquainted with the app folder. If this folder is not opened, double click to open it. You will see three subfolders:

  1. Manifests - a folder containing an application manifest. This is an XML file that contains special settings for our application and information that the Android system uses to run the application. This information can refer to permissions(for example, Internet access permission), internal component devices on which your application can run (for example, some sensor is required), Activities, application name and Activities titles, icons, and so on. We will discuss more this in later chapters
  2. The java folder - which contains packages with code written in java. These packages(folders for grouping code) are by default divided into three types:
    1. A package with the name of your project is a package that contains all code (and possibly other packages) associated with your project. There may be classes for Activities, classes for some database connection, a connection to the Internet, and so on. That is, those same classes that we write in ordinary java, but sometimes using the capabilities of Android.
    2. A package with the name of your project and the tag androidTest is a package that contains the code associated with instrumental testing. Testing (automatic) is an approach that allows you to check the functionality of our application with the help of pre-written code without human actions. This means that a person does not need to repeatedly enter the same data to test the application's performance, instead, the code does it for the person. Instrumental testing is testing, which is aimed at using our code, where the Android API is mandatory.
    3. A package with the name of your project and the tag test is a package that contains the code associated with the module testing (module is equal unit). Unit testing is an approach to testing individual parts(units) of our application.
    Java Folder
  3. Finally, the res folder is the folder that contains the resources of our application. By application resources we mean:
    1. Images that we can use in the project (the drawable folder).
    2. Layout for screens (Activities) and some different elements. Layout - arrangement of elements on the screen (the layout folder).
    3. Icons of our application, which are used on different devices in the menu and in other places (the mipmap folder).
    4. Strings, numbers, dimensions, colors are those data that can be repeated on different screens, but must always be the same in whole application (the values folder).
    Res Folders

Now that we have briefly studied the structure of our project, we will examine how all these elements interact with each other.

Post a comment


Nothing the first to share wisdom.