Skip to end of metadata
Go to start of metadata

Redirection Notice


An Android project is primarily a Java project so it shares many of the classic folders you find in a Java project. Let's find out more.

1. Open the Project View

By default, the project view is collapsed to the left edge. To open it and view all of the constituent files, you click on the Project tab (as in the figure) or just press Alt + 1.

 Opening the project view reveals the typical structure of an Android project: it is analogous to the structure of most Java projects.

2. Snoop into code-related folders

The source code (activities and other helper classes) are located under the src folder; resources are grouped under the res folder. General properties of the project are available instead in the AndroidManifest.xml file located in the root project directory. Let's expand on.

The .idea folder

The folder contains a few subfolders and various XML files, mostly filled with internal IntelliJ IDEA information and general settings.

Note: You usually have no reason to interact with the content of this folder.

The gen folder

The folder contains Java source files automatically generated by the Android platform tools during the build process. If you explore the folder, however, you find it contains a few stub .java files that only exist for the sake of IntelliJ IDEA. In particular, you'll notice a and a stub file. The former is generated and then compiled into the final Android package to contain application resources. The latter, instead, contains public manifest information about the application. This information is ultimately used by the Android operating system while installing the application on a device.

Note: You usually have no reason to interact with the content of this folder.

The src folder

The folder contains all the source files that make up the application. You can have as many levels of subfolders under the src folder as you like to better reflect structure and complexity of the application.

The libs folder

The folder is expected to contain all class libraries (.jar files) you want to reference from the source files of your application. You can simply drag-and-drop .jar files from disk into the folder.

3. Snoop into resource folders

The res folder contains all external resources used by the application such as images, layout files, strings, menus, and any other auxiliary information that may be useful. Often this information is expressed through XML files. Under the res folder there are usually the following subfolders: drawable, layout, values, and menu.

The drawable subfolder

The drawable folder contains all of the images you reference from within the application. This includes the application's icon, the splash-screen image as well as any other images you use to embellish the user interface.

The layout subfolder

The layout folder contains layout files used to define the structure of views. A UI layout file is ultimately an XML file that you can edit manually in IntelliJ IDEA or, better yet, edit through the integrated graphical designer.

The values subfolder

The values folder contains XML files that declare strings, graphical styles, and colors. Usually, data stored in such XML files is expressed in the form of name/value pairs. The primary reason for isolating resources in a folder is for the ease of localization.

The menu subfolder

The menu folder contains the definition of menus to be used by the application. A menu is expressed as an XML files and consists of a list of items each of which indicates a unique id, a reference to a string in the values folder and reference to an icon in the drawable folder.

The assets folder

This is an optional folder also aimed at storing resources. The main difference with the res folder is that any content placed in assets is not going to be pre-processed by the Android framework as it happens with strings and images and any content in res. The benefit of resource pre-processing is that the resource is abstracted to a generic id which enables the underlying Android platform to serve the most appropriate version of that resource based on languages, OS versions, and screen size or orientation. The content in assets is provided as-is and the developer is responsible for reading it programmatically.

4. Snoop into the manifest file

A manifest file is required for every Android application. The manifest must be an XML file named AndroidManifest.xml and must be located in the project root folder. The manifest presents general information about the application to the Android operating system. This information is essential for the operating system to run the application.

Application properties

The manifest declares the package name and version as well as the version of the minimal Android SDK required for a device to run the application. This prevents the application from being installed on unsupported devices.
The manifest also declares the entry point in the code for the operating system to launch the application along with permissions the application requires from the user and lists system components it relies upon.

Reasons to change the manifest

As a developer, you need to edit the manifest file manually for two main reasons: when you add a new activity to your codebase and when you need to access programmatically functions that require permissions such as local storage, sensors, and Internet.


  • No labels