Hey! Welcome to MyAwesomeSite.com! We will be cursoring through all the steps required to setup your PC (environment) so that you can build and run Android applications. We won’t just be monkeying steps or copying code, we will be completely understanding what is going on. The awesome people at Google have a comprehensive documentation at developers.android.com. It is up-to-date with the latest version and code of Android. This will be your bible for Android development here-onwards.
Note: We are working on a Windows PC
Section 1 – Environment setup:
We need the following things to get started:
- Android SDK
- An IDE like Eclipse
Go right ahead and download the latest version of Java from their official website. Install Java and modify your
JAVA_HOME environment variables. These variables make Windows aware of your Java installation. Say you installed Java at
C:\Program Files\Java\, your
JAVA_HOME will be
C:\Program Files\Java\jdk. And you will have to add
C:\Program Files\Java\jdk\bin to your
PATH environment variable. You can check if you have installed Java properly by typing
java -version in your command line.
We now need the Android SDK and Eclipse.
The Android Software Development Kit (SDK) is required to build and test your applications. When we begin writing an application, the code will be in pure Java. While building the application, this code is converted to Dalvik code, which is understood by the Android OS. Once an application is built, it is packaged into an APK file. This file is used to install your application on a phone. Well, there’s more to it but we’ll get to that part later.
To help us code better, we need an IDE. We will be using Eclipse for this purpose. To make our life easier, Google already provides the ADT bundle. This bundle contains Eclipse + SDK tools + ADT Eclipse plugin + other geeky stuff required for building your application. The ADT Eclipse plugin makes your Eclipse compatible to understand Android projects/code.
Download the ADT bundle from their official website. Be sure to download a version compatible for your PC. If your PC is 32 bit, you will need a 32 bit version of ADT. Same applies for a 64 bit PC. It’s one heck of a download so keep it running while you eat.
Wash your hands and extract the package to a suitable location. We have to modify the
PATH variable to make Windows aware of our SDK’s location. Say you extracted the ADT bundle to
D:\Android\ADT\sdk\tools to your
PATH environment variable.
Now run the Eclipse from your ADT bundle and open your preferences.
A new dialogue will open. Select “Android” from the menu on your left-hand-side.
Eclipse is asking for the location of your SDK tools. You will find it inside your ADT bundle. If you have extracted the ADT bundle to
D:\Android\ADT, your SDK tools will be located at
Press “OK” and you are done with the environment setup.
Section 2 – Creating a new project:
Go to File -> New -> Android Application Project
The Project Name is used only by Eclipse to identify different projects in your workspace.
The Package Name is a unique identifier used to distinguish your application from all the other apps out there. The general convention is to reverse the name of your website. So, if your website is example.com, the package name will be com.example.myfirstapp (Notice we append the application name at the end).
Press the “Next” button. You will see another screen with some options. There’s no geeky stuff here, just simple options. Better not to touch any options here. Just make sure you have kept Mark this project as a library unchecked. If you keep it checked, your application will be used as a code base for another project. It will generate a .jar file and not a .apk file.
The next screen gives us an option of configuring our app icon. The app icon will be used when you install your application. It’s used in the Google Playstore as well.
In the next screen you can select the basic layout of your application’s first page. This page is called an Activity. Similarly, all the pages you see in your application are Activities. We need a simple Activity for this tutorial, hence just select Blank Activity.
On the next screen you will see options to select the names of your first Java and XML files. Name them according to your convenience and click “Finish”
You will now see a new Android project created with the name you had given. Eclipse automatically opens 2 files for you. In this case they are MainActivity.java and activity_main.xml. These two files work together to create a single page in your application. Huge applications have many such pages (Activities). For each Activity, you will have one .java file and one .xml file.
- Exploring Eclipse
- Exploring the project folder structure
- Creating a virtual device to run your application
- Running your application on a virtual device