Sunday 8 November 2015

Android Studio Project Structure


Android Project Structure
In this blog i have explained Android project structure and file organization in detail, by creating a new Android project in Android Studio. When we start a new Android project in Android Studio, it will automatically creates a lot of files and folders for us. We will look at the meaning and functions of each of these folders in the Android project structure one by one.
You have to create a new Android project in Android Studio to see the project structure.Follow the below steps to create a project in Android Studio 


Open Android Studio

If you have only just installed the Android Studio, it will show you a window like this. Otherwise go to File-> New Project.



Click the first option, that is Start a new Android Project



Enter a company name of you own. Leave all other fields unchanged and click Next.





Select only Phone and Tablet. In the Minimum SDK Select API 15. Read the description of the minimum SDK to get things clear. Click Next.

In the next window Select Blank Activity and click Next.





Leave all the fields unchanged and Click Finish.

Now The main window of Android Studio opens and in the left most pane of the window, You can see the Android Project Structure.



Here is the brief description of important files/folders in the Android project structure:
1. Manifests


AndroidManifest.xml is one of the most important file in the Android project structure. It contains all the information about your application. When an application is launched, the first file the system seeks is the AndroidManifest file. It actually works as a road map of your application, for the system.

The Android Manifest file contains information about:
Components of your application such as Activities, services etc.
User permissions required
Minimum level of Android API required

2.Java
The Java folder contains the Java source code files of your application organized into packages. You can have more than one package in your Android application. Its always a good practice to break the source code of your application into different packages based on its core functionality. All the source files of your Activities, Services etc. go into this folder. In the above screen, you can see the source file of the Activity that we created for our project.
3. Res


Res folder is where we store all our external resources for our applications such as images, layout XML files, strings, animations, audio files etc.

Sub folders:
Drawable


This folder contains the bitmap file to be used in the program. There are three different folders to store drawables. They are drawable-ldpi, drawable-mdpi, drawable-hdpi.The folders are to provide alternative image resources to specific screen configurations. Ldpi, mdpi & hdpi stands for low density, medium density & high density screens respectively. The resources for each screen resolutions are stored in respective folders and the android system will choose it according to the pixel density of the device.

Layout

XML files that defines the User Interface goes in this folder.

Values

XML files that define simple values such as strings, arrays, integers, dimensions, colors, styles etc. are placed in this folder.

Menu

XML files that define menus in your application goes in this folder
4. Gradle Scripts


Gradle scripts are used to automate tasks. Now we don’t have to bother much about this, we will cover it later. Only understand that we use this Gradle Scripts to automate certain tasks. It uses a language called Groovy.

2 comments:

Android Studio Project Structure

Android Project Structure In this blog i have explained Android project structure and file organization in detail, by creating a new An...