In this post we will learn how to make a simple Hello Android with Android 1.5 or 1.6. Open your Eclipse and let’s go:
#STEP 1 – Create a new Project
File -> New -> Android Project
After that you will see something like this:
Ok, is time to fill the fields:
PROJECT NAME: Type a nice name for your project (it can be easily changed later)
CONTENTS: “Create new project in workspace”. It’s our first project.
BUILD TARGET: Select Android 1.5 or Android 1.6. Don’t worry about Google APIs option for now.
- APPLICATION NAME: The name of your application. This name will be shown to the user.
- PACKAGE NAME: Type the root package of your project. E.g.: com.you.helloAndroid.
- CREATE ACTIVITY: Type the name of your main activity. (Don’t know what Activity is yet? Don’t worry. I will explain it the next posts. But if you can’t wait for that, click HERE.
- MIN SDK VERSION: Type 3 if you choose Android 1.5 or type 4 if you choose Android 1.6. With this identifier you can define SDK target of your application. E.g.: if you type 3 for MIN SDK VERSION you’re assuming that your application will run only on devices updated with Android 1.5 or later.
Well, click FINISH.
#STEP 2 – Making the Hello Android happen (so so)
After Step 1 our Hello World is almost complete! “Really? No more code is needed?” Yes, no more code is needed. You must for now change the default “Hello world” message to something you like.
In Package Explorer (Eclipse) open the strings.xml file of your project (res/values/strings.xml):
You will see something like this:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, MainActivity!</string> <string name="app_name">FirstApplication</string> </resources>
Change the text “Hello World, MainActivity” for something you want.
#STEP 3 – Executing the Hello World
Create an AVD (Android Virtual Device) before to execute your project. AVDs were available since Android 1.5. The advantage of them is to create many devices with different configuration and test your project on them.
Well, click on this almost hide button on Eclipse (near Save button):
Click in the NEW… button and follow the fields (ignore SD Card field for now):
Click CREATE AVD….
Now go to RUN CONFIGURATIONS… option for creating a New Configuration to your project:
Select the AVD you created previously:
Click APPLY and then RUN! Now wait for the loooong Emulator loading… when the Android desktop is shown, unlock the screen by pressing MENU and wait your application be opened:
Well, this is enough for now. Congratulations for your next Android program! Keep going on!