Welcome to Android! Part 2.

Hey! Welcome back! We have covered the basic environment setup and created a blank application in our last part. Before we actually begin coding, it is essential to understand how to use Eclipse and the project structure of Android. Let’s begin with the Android project structure.

Section 1 – Project structure:

Here is an overview of the project structure. Don’t panic, it’s really simple. We will go through all the important folders and understand their importance.

project structure

  • src – contains all your Java packages and files.
  •  gen – contains the files generated after your project is built
  • assets – contains the raw files used in your project. (sound files, videos etc.)
  • libs – contains all the external libraries required for your project. Libraries are packages/files written by other coders to help you. Yes, there are good people out there
  • res -> drawable – contains the generic images and xml files
  • res -> drawable-**dpi – You will notice 5 folders inside res named as drawable-ldpi, drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi. Each folder holds images/xml files for a specific range of device resolutions and densities. We will be using these folders to adapt our application to the variety of densities and resolutions
  • res -> layout – contains all the xml files which create the structure of your Activities
  • res -> menu – contains all the xml files which make the menu in your ActionBar
  • res -> values – contains all the xml files which hold dimensions and strings accessed by your application

There are two important files we need to keep in mind :

  1. AndroidManifest.xml – contains the project’s permissions, declaration of Activities and Services. (Activities and Services will be covered in future tutorials)
  2. R.java – R.java is an auto generated file present in gen->”package-name”/. It contains unique identifiers (normally 32bit numbers) for elements in each category – drawable, string, layout, color, etc. The main purpose of R.java file is quick accessibility of resources in the project. If any resource modified, R.java file will be generated automatically.

That takes care of the important files and folders. You will find yourself referring back to the list for the first few times. Once you get used to it, you’ll know them like the back of your hand.

Section 2 – Exploring Eclipse:

Eclipse is our Android friendly IDE. Google has come up with their own IDE as well, it’s called Android Studio and uses Gradle (Eclipse uses ANT) for building projects. The ADT bundle comes with the latest version of Eclipse ADT which we will be using. This first thing we do is to activate the Dalvik Debug Monitor Server (DDMS) perspective. Go to Window->Open Perspective->DDMS

opening ddms

Eclipse will open the DDMS perspective for you which looks like this by default. If it’s not opened, you can click the DDMS button on the top right of your Eclipse window.

ddms default

What is this DDMS thing? It’s a great tool to help you monitor and debug your Android application. It provides a lot of information about your application’s performance and current state. Here are the most frequently used sections in the process of development:

  • Devices – This sections gives us a list of all the connected devices/virtual devices and the applications which are running in them.
  • Logcat – The Logcat is for viewing the messages printed in your program using the Log class. Messages written in System.out.print() will also appear here. You can select the Log Level using a drop down. Available choices are Verbose, Debug, Info, Warn, Error. You can also filter the log messages if needed.
  • Network – If your application deals with heavy network activities, you can view the network usage under this section.

We will need these for the forthcoming tutorials.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s