For those of you who are beginning to start on working on Android projects, then this is for you. In this tutorial you'll know the basics on how to create your first working Android application. But as a refresher course, let me first introduce you what are the core components of Android. Basically, it is made of Java and XML for the UI and designating parts. If you have already have background knowledge with Java then this will be a walk in the park for you. But for those who haven't, don't worry as this tutorial is as easy as it can get.
But before we can make a simple "hello world" project, you need an Android Virtual Device (AVD) this is the program that you need to run your project. Although you can use a real phone, but we'll stick to the emulator on the mean time.
First you need to install the following.
ADT Eclipse Plugin
1. Download and Install the Android SDK
Install the Java SE Development Kit 7. Select "Accept License Agreement" and download the correct executable file for your system. If you are using Windows, then you can either choose x86 version for Windows 32 Bit and x64 for 64 bit operating systems.
After which, install the Android SDK just like a normal program. Click on next and once it is done you can execute and run the program. For the sake of this tutorial, you can choose "SDK Platform Android 2.2, 2.3". Higher versions are still okay. After which, Click "Install Selected" to start installing the packages.
2. Installing Eclipse.
Install Eclipse by downloading the appropriate files. Once you get the zip files, you can extract it and choose the "eclipse.exe" file to run the program.
3. Running your first program.
Open Eclipse, at the top window, click Window -> Android SDK and AVD Manager.
The highlighted section on the left should be highlighted Virtual Device.
On the top right button, select "New" then "Create a new AVD" with the same settings as indicated in the screenshot. This should create an Android emulator on your screen.
After which, fill out the "Name" and select "Target" then click "Create AVD"
4. Starting your hello world program.
Go back to Eclipse, and select window and click File -> New -> Project. Once there, go to the Android folder and select "Android Project".
Input the following,
Name - name of your project.
Select the Target - the android version you wish your project to launch. You can choose Android 2.2
Package Name - depends on your Application name, you can write HelloWorld.
After which select next.
You screen should be the same as above.
Click the "src" folder, and you should see your Java file depending on the file name. So if you entered HelloWorld, there should be a java file named HelloWorld.java. Double click the said file.
5. Dissecting the Java file.
The second line (TextView tv = new TextView(this);) allows you to output the word "Hello Android".
The third line (tv.setText("Hello World")) holds the said text on the tv object that will then later on be outputted.
The fourth line (setContentView(tv);) Outputs the tv object. So whatever contains inside it is displayed.