Signup/Sign In

Android App Project Package Structure (Android Studio)

In our previous tutorial, we learned how to create our first Android Application and how to run it. When we create an android project, Android Studio generates the application project with a few default packages and folders. Here, in this tutorial we'll discuss about the project structure of an Android Application.

Earlier a lot of Android Applications were developed on Eclipse IDE, but now-a-days one can only develop an Android Application using Android Studio, else Google will not allow the application to be made public or even reject the application from Google Play Store. For those who have apps which were developed using Eclipse and now plan to shift the code to Android Studio, this lesson will help you to understand the structure of both the developments tools.

First we will understand the project structure of Eclipse IDE(If you are a beginner, you can skip this part). For that we will assume that you have a basic "Hello World!" Android Application created in Eclipse IDE. Both Eclipse and Android Studio require same steps to create an Application Project, only minor differences are there.


In Eclipse, every Android project structure includes the following folders,

  • src
  • gen
  • Android Version
  • Assets
  • libs
  • res
    • drawable
    • layout
    • anim
    • values
  • AndroidManifest.xml
  • default.properties

Package Structure in Android

These are the default folders which collectively form a Android Application project along with two other files, one is AndroidManifest.xml and default.properties. There are other folders as well like bin and referenced libraries.

As most of the folders created in Eclipse are still created in Android Studio with some changes in the directory structure, hence we will explain them all in the next section where we have explained Package Structure of Android App in Android Studio.


Package Structure in Android Studio

In Android Studio, the modern day Android App package structure has changed a little bit, but the change is very subtle.

Here is a list of folders created, when you create an Android App project in Android Studio and see it in Project View Mode:

  • app
    • build
    • libs
    • src
      • androidTest
      • main
        • java
        • res
        • AndroidManifest.xml
  • gradle

NOTE: The packages which are written in bold font are important packages.

Package Structure in Android


src folder

The src folder holds two most important folders on any Android project, namely, androidTest and main.

The androidTest package is created to hold Test cases for testing the application code and running.

While the main folder, has 2 folders and 1 file. They are:

  • java directory

    This folder contains .java (JAVA) files. Here, you can create interface(s), activity(s), fragment(s) or adapter(s) for your application. This folder contains java code only. You can create separate packages for each of these and create classes inside them to give your application project a well defined structure.

  • AndroidManifest.xml

    This file is a mandatory file for any android application. In this file we provide information about all the application's Activities, Services, Broadcast Receivers etc and all the permissions like Internet, Contacts, Camera etc that our application will require when it is installed on any device. Just keep in mind that this file is the heart of any Android Application.

  • res directory

    This folder contains all the resources like icons, images etc related to our application project and it contains the following sub-folders:

    • drawable
    • This folder contains xml, png, jpg and jpeg files. In this folder you can store images which are used in your app and other .xml files which are used for many purposes like creating button background, or shadow effect etc.

    • layout
    • This folder contain only the layout .xml files for different screens and parts of your application.

    • values

      This folder contains default files like strings.xml, dimens.xml, colors.xml, styles.xml.

      • In strings.xml, you can specify all the string constants like title of screen or any other tag which are constantly used in your app.
      • In dimens.xml, you can create different .xml files to define dimensions as per resolution of screen and dimension of it and give any dimensions for padding, height, width, margin in this file.
      • In color.xml you can mention the list of colors using their hashcodes, used in your application. If this is not created by default, you can create this yourself.
      • In styles.xml you can define different readymade styles to use them directly anywhere in your Android App.

build Folder

This folder contain R.java file, which is an auto generated file. This file indexes all the resources of the android application project like layout xml, strings xml etc and it is auto generated.

In build folder, you will have application's debug and release apk files, created when you build your project.


libs folder

If you want to use any external library, all you have to do is copy-paste the .jar file into the libs folder and then you can directly use it in you .java code files.


gradle folder

In this folder there are files related to gradle which can be modified to alter the project building process. For example: If you wish to run all the available test cases before building the .apk file, you can do so by mentioning it in the gradle file.


So now you know about the details of each and every ready-made folder of your Android Application project. As we move ahead with the lessons you will get to know more about these folders and types of files that they contain. The upcoming lesson contain information about Gradle(build system for Android Studio).