Introduction: How to Write a 'Hello World!' App for Android
This tutorial is meant for anyone who has no experience in programming applications for the Android operating system, but would like to. It is very basic, and installing the necessary programs is more complicated than writing the application itself. Once the programs are installed, it should only take a couple minutes to read the tutorial and have your program up and running. The code for this tutorial is explicitly given to you. If you feel like you might be interested in this, you should begin learning the programming language Java. This guide assumes that you have some knowledge of how to install and run programs.
THINGS YOU'LL NEED:
Please check that your computer meets the minimum requirements, here .
If it does not, you will not be able to complete the tutorial.
Java SE Development Kit 7
Eclipse for your operating system
TIPS AND WARNINGS:
Tip/Warning: Follow the installation instructions exactly
Warning: Cannot run on a Mac, as not all the programs install on a Mac
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Installing Java SE Development Kit 7
This guide assumes that you know how to install a program, but if you don't, please view this guide.
Install the Java SE Development Kit 7 (JDK for short).
Select "Accept License Agreement" and download the correct executable file for your operating system. If you are using Windows and you do not know what operating system you have, just download the "Windows x86.exe" file.
The JDK is a development environment for building applications, applets, and components using the Java programming language. The JDK includes tools useful for developing and testing programs written in the Java programming language and running on the ava platform. Since Android applications are programmed using the language Java, this program is necessary.
Step 2: Installing the Android SDK
Install the Android SDK just like a normal program, clicking Next and installing it in the location you wish to save it in. Once that it done, find the executable and run the program.
A window will pop up and after it is done loading, you can close the window titled “Choose packages to install.”
On the left side of the Android SDK window, there are 5 options.
Click on the one titled “Available Packages” and click ‘Android Repository.’
For the sake of this tutorial, you should only install "Android SDK Platform Tools, Revision 2" and "SDK Platform Android 2.2, API 8, revision 2."
It is completely possible to complete this tutorial if you have a different SDK Platform installed.
Both of these options can be seen in the picture included with this step.
Click ‘Install Selected’ to install the packages.
Note: If you are prompted to restart your computer after the packages install, do so.
Step 3: Install Eclipse
The last program you need to install is what you will use to do your programming in.
InstallEclipse by downloading the appropriate .zip file and extract the contents to a folder you will remember. Once the contents are extracted, all you need to do is run the "eclipse.exe" file.
Step 4: Setting Up Eclipse
Finally, we’re ready to get programming. We will be creating an AVD. An AVD is an Android Virtual Device, otherwise known as an emulator.
Open Eclipse .
At the top of the window, click Window -> Android SDK and AVD Manager.
The highlighted section on the left should be highlighting Virtual Devices.
Click the top right button, New , and create a new AVD with the same settings as the picture.
When you have filled out the "Name" and selected a "Target," click "Create AVD."
I am using Android 2.2 for this tutorial because that is what my phone uses. It is not the only Target you can write this program on.
Step 5: The Beginning of Your 'Hello World' App
Go back to the Eclipse window and click File -> New -> Project.
Once there, go to the Android folder and select “Android Project,” clicking Next when you have selected it.
Make the appropriate changes to your Project window (as shown in the second picture):
Change the name
Select the target
Name the application
Change the package name
Click Finish when you have made the changes.
Step 6: The Guts of the Application
If your screen does not look like the image, navigate over to the left side under HelloWorld and click the arrow to the left of src.
Nowclick the arrow to the left of com.example.helloandroid.
Double click HelloWorldActivity.java and your screen should look the same.
If the code is missing the 3rd line, that’s okay.
Step 7: The Actual Code for Your App
Type the following lines code into the corresponding highlighted lines from the image:
1st Line: import android.widget.TextView;
This line allows you to output text to the screen.
2nd Line: TextView tv = new TextView(this);
This line is necessary if you are going to put out 1 line. In this case, that line is Hello World!
3rd Line: tv.setText(“Hello World!”);
This line (as you can guess) outputs the text Hello World! to the screen.
4th Line: setContentView(tv);
This line goes back to the second line and actually outputs the text to the screen.
With those lines of code, you have successfully created an App to say Hello World!
Step 8: Running Your App
To run the program, right click your HelloWorldproject on the left side.
Move down to Run As and select Android Application .'
The emulator will take a while to open, but it will eventually run your application, so just be patient.
Congratulations, you have now written a successful Hello World application for Android.
For more information on furthering your skills, please see the next step.
Step 9: Further Information
So you want to learn more about making applications for Android? That's great, but nothing you ever create will be as simple as this Hello World application was.
You will need to begin to learn java. Two very good websites are located down below that will help you learn the basics of Java and Android programming. Once you're ready to put an app on the App Store, look here .
This guide was meant to be a stepping stone for those who are interested in programming Android applications in Java. For more info, please visit The Java Tutorials and Android Developers .
1 Person Made This Project!
- AvinashB15 made it!