Tech and Media Labs
This site uses cookies to improve the user experience.

Android Project Overview

Jakob Jenkov
Last update: 2014-10-28

When you create a new Android app project from scratch it contains a lot of files and directories from the beginning. Browsing around these files and directories can be quite confusing when you don't know what their purposes are. Therefore I will shortly explain the core files and directories of an Android project in this text, so you can get an overview of what an Android project contains.

Here is screenshot of the directories and files in a newly created Android Studio project:

Android project directories and files overview.

As you can see, the Android project is located in some directory which contains a lot of files and subdirectories below it. I will explain these subdirectories and files below.

The app directory is the root directory of all files directly related to your app. These files and directories you are allowed to edit to some degree. By "some degree" I mean that some of the files and directories have to exist while others do not.

The src directory contains all of the source code for your Android app. Inside the src directory you have two directories called androidTest and main . The androidTest directory is for test cases for your Android project. The main directory contains the main source code for the Android app.

Inside the main directory you have two directories named java and res.

The java directory is the root of the Java source code for the Android app. In here you can put Java packages and classes like you are used to in a normal Java project. You are free to organize your code any way you like, but there is one significant restriction on your package hierarchy. The Google Play store identifies your app based on its core / root package hierarchy. Once you have published the app once to Google play, you cannot change this core / root package hierarchy if you want to publish updates to the same app via Google play.

As an example, imagine you create the core / root package structure com.jenkov.mynewapp . Inside mynewapp you will have the various classes and subpackages that make up your app. The core / root package com.jenkov.mynewapp will be used as identifier for your app in the Google Play store, so once you have published your app one time, you will have to keep this core / root package structure forever for that app.

The res directory inside the main directory contains all the non-Java sources for the Android app. The non-Java sources include various XML files and image files. Many of these files are located in subdirectories of the res directory.

One important XML file is located directly in the res directory: The AndroidManifest.xml file. The Android manifest file contains a lot of information about the Android app, including the identifying core / root package hierarchy under which your app is located (in the Java package structure). The AndroidManifest.xml file also contains information about the name and version of the Android app.

The directories which names start with drawable contains the image files used in the app. Each directory contains the images for use with different screen resolutions. Some Android devices have much higher screen resolution and pixel density than others. To make the images look good on all these devices, each image must exist in a resolution matching the device resolutions your app targets. For higher resolution screens you will have to use higher resolution images. The Android device will automatically choose the right image from these folders depending on its screen resolution and pixel density.

The layout directory inside the res directory contains the layout XML files used by the app. Layout XML files are typically used by activities, fragments and by some ViewGroups. These layout XML files specify how the GUI components in the app is to be rendered.

The menu directory inside the res directory contains the layout XML files used by the app's menu (ActionBar).

The values directory inside the res directory contains XML files with value definitions. For instance, the strings.xml file contains text labels to be displayed in the app. Having the text labels in a separate file from the app makes it easier to translate these labels to other languages without touching the Java code.

There are a few more files and directories than what I have covered here, but I have explained the most important of the files and directories.

Jakob Jenkov

Copyright  Jenkov Aps
Close TOC