Exploring the Project Structure
An Android project is primarily a Java project, so it contains many of the standard folders you find in a Java project. Let's find out more.
In this tutorial:
- Open the Project View
- Explore Code-Related Folders
- Explore the Resource Folders
- Explore the AndroidManifest.xml File
Open the Project View
If the project view is collapsed to the left edge, click Project in the left gutter, or just press Alt+1.
When you expand the Project tool window, it shows the typical structure of an Android project that is analogous to the structure of most Java projects:
Explore Code-Related Folders
An Android project contains the following key folders and files:
- .idea folder: contains a few subfolders and various XML files that mostly contain internal IntelliJ IDEA information and general settings. Normally, there is no need to edit the contents of this folder.
gen folder: contains Java source files automatically generated by the Android platform
tools during the build process. If you explore this folder, you'll find that it also contains a few
.javafiles that only exist for the sake of IntelliJ IDEA. In particular, you will notice the
R.javafile is generated automatically and then compiled into the final Android package. It contains the IDs of all application resources (such as drawables, layouts, strings, etc.), whether assigned by the programmer or generated by the SDK.
Manifest.javafile contains public manifest information about the application. This information is used by the Android operating system while installing the application on a device.
Normally, there is no need to edit the contents of this folder.
src folder: contains all source files that make up the application
(activities, helper classes, etc.). You can build any hierarchy of subfolders under the
srcfolder to better reflect the structure and the complexity of your application.
- res folder: contains all project resources, such as drawable resources, layouts, etc. (for more details, see Explore the Resource Folders).
libs folder: contains all class libraries (
.jarfiles) that you want to reference from the source files of your application. You can simply drag-and-drop
.jarfiles from the disk into this folder.
Explore the Resource Folders
res folder contains all external resources used by your application, such as image assets,
layout files, strings, menus, etc. Most resources (except for images) are expressed through
res folder usually contains the following subfolders:
drawable: contains all images you reference from within the application. There are actually
four different drawable folders designed to contain images in different resolutions for devices with different
screen density (expressed as
dpi- dots per inch):
- hdpi (high density, 240)
- ldpi (low density, 120)
- mdpi (medium density, 160)
- xhdpi (extra high density, 320)
Designing drawable resources in different resolutions is required to support different devices and multiple screens (for more details, see to Supporting Multiple Screens).
layout: contains layout files (
.xml) used to define the user interface of an activity or an application widget. You can edit layout definition files manually, or through the integrated graphical designer (for more details, see Designing Layout of Android Application).
.xmlfiles that declare strings, graphical styles, and colors. Normally, data stored in these files is expressed in the form of name/value pairs.
menu: contains definitions of menus to be used by the application. The
menufolder is not generated when you create a new project, and only appears in the project structure after you have created the first menu.
Explore the AndroidManifest.xml File
Each Android application must have the
AndroidManifest file in its root directory. This file contains
general information about the application processed by the Android operating system. This information is
essential to run the application.
Among other things, the
AndroidManifest.xml file declares the package name (that serves as a unique
identifier for your application), and the minimal version of the Android SDK required for the device where
the application will run. It also declares the entry point in the code for the operating system to launch the application,
along with permissions the application requires. For more details on the
AndroidManifest file, see