Android basic application file structure

Before we move forward to learn

Android development tutorial

from scratch; we must have to understand Android application architecture. Which atually recognized by the android system and IDE’s.

An Android application consists with many image-video-gif or any media items, Graphical User Interface(GUI) design, System information, Web information and interactions.

Let’s see a basic Android application structure. This tutorial prepared in assistance for beginner’s level. That doesn’t show you actual programming process but understanding the basic project structure. Thus, it’s very effective in the process of Android development tutorial.

Few things we need to keep in mind before we dive into this android development tutorial :

  1. Android application graphics is initially handled by XML but you can also perform graphical stunt using Java.
  2. Build.gradle is the core project class identification file where we have to familiarize the application which are going to use. Yes I Mean libraries and library resources.
Android application file structure

Android basic application file structure

The infograph above shows you basic structure of android source code. Let us go in deep.

Let’s assume you have created a new android project in android studio named as kickwe. Navigate to kickwe folder. You will see some files and folders. I’m mentioning only important among them :

  1. app (folder)
  2. build.gradle (root project gradle file)

Here, app contains all the necessary files which we are going to make. Some are automatically generated by android studio as well.

Root build.gradle , this folder is very important. Here you need to declare source of libraries which you are going to mention in module build.gradle.

Example :
buildscript {
repositories {
jcenter()
}

Inside the app folder we will see below one folder named main. Going through that main folder, there are few more files and folders which play vital role regarding the android development tutorial e.g:

build

It has all generated files made by the IDE. You don’t need to worry about it,  those are automatically created. However for some troubleshooting you might need to delete this libs folder to reset & make further generated files.

libs

Above folder is initially empty. If you want to use any .jar library, you can place them here. Any library will be automatically added if you places .jar files e.g:volley.jar here (you will need to declare that in module build.gradle).

build.gradle (module gradle file)

This is the build.gradle file where we are going to mention about application supported os API, application version, all libraries name we are going to use and apply any plugin if necessary.

Example:

  • src contains only one important folder addressed as  main. Inside, it has most important folder that contains two folders and one file .

manifest.xml

This file provides essential information about your application to the android operating system. This can be about required permissions or activity lists and themes.


res

  • res
    • layout
      • activity_main.xml
      • activity_second.xml
    • values
      • colors.xml
      • dimens.xml
      • strings.xml
      • styles.xml
    • drawable
    • menu

In res section there are several folders, let’s just notice what it does but remember these are just for good practice and not necessary to always maintain this.

Layout

It contains several XML files which is called through Java files. Placing all your layout XML files here are good practice. So lets follow those on our android development tutorial process.

Example :
activity_main.xml
activity_second.xml

Please note: xml file name can’t start with numeric number and capital letter. Also there are limitations to use symbols as well.

values

It may contains 4 files.

  1. colors.xml
  2. dimens.xml
  3. strings.xml
  4. styles.xml

colors.xml usually contains all the colors used often in your application. Specially the Google material design guideline recommends you to define primary color, accent color and primary dark. Indeed these are just proper way of android application development, not obvious.

Example:

dimens.xml usually contains  frequently used dimensions in the application.

Example:

strings.xml lists all the static strings you are going to use in the application. You can also write directly string in other layout xml or Java files but these is also part of good practise.

Example:

styles.xml defines overal theme preferences and connects with colors.xml.

Example:


drawable

Mostly images used by the application which is user defined. It can contain some xml that defines vector or svg images. Remember , the application icon (ic_launcher.png)  also belongs here.

  • Menu (optional)

along with other it’s menu.xml that provides menu item names.

Example:


java

This is where you are going to program the application. Ultimately you may have seen there are several folders inside it, which is automatically generated according to your choice. While you choose your package name at new project wizard of Android studio.

Example : com.android.development.tutorial

PS: this can’t contain capital letter.

After that you will see only one class file made by Android studio called activity_main.java

Alright now keep writing more on the blank project. How ? Next we are going to start practice & experiment through various example of Android development tutorial 🙂

________________________________

Bellow you may find offline version ‘Android development tutorial- android basic project file structure’ pdf

 

Post A Reply