Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile / Android

Creating a Simple Hello World Android Project

5.00/5 (1 vote)
5 Aug 2014CPOL3 min read 24.7K  
In this tutorial I will explain about the basic components of an Android application and show you step by step how to create, fix, and test your first android application.

Introduction

This step by step guild is packed full of screen shots to guide you in the journey of creating a simple Hello World application. Ready to code?

Background

This tutorial was made using Windows 8, Eclipse Platform 4.2.2 and the Android ADK 23.0.2.1259578.

Lets learn...

Step 1: Definitions and Basic Components

Minimum SDK = This is how far back you wish to go in regards to the Android OS.

  • You want the minimum SDK to go as far back as possible. Keep in mind if your application uses something introduced into the Android OS version 4.0 or higher, then your minimum needs to be 4.0.

Target SDK = Is the Android OS you have in mind for developing this application

Compile With SDK = Is recommended to be set to the most recent stable SDK in the market.

  • For this you will want to set the compile with SDK to the highest stable Android OS. This is so that your target audience can still use your application if the receive an Android OS update.

The Basic Components are...

Image 1

Resources...

Image 2

Step 2: Launch Eclipse

Image 3

Step 3: Create Project

Image 4

Image 5

Image 6

You can use this public domain image for the next step.

Image 7

Image 8

Image 9

Image 10

Image 11

Step 3: Review and Update your application

Image 12

Lets find out why...

Image 13

Lets fix it....

Image 14

Image 15

Image 16

Image 17

You could also change the theme to something compatible or create a custom theme using styles, if you prefer.

Image 18

Image 19

Image 20

Image 21

The Graphical Layout tab gives you an idea of what the user will see. There are widget tools you can use to create your layout and GUI interface by dragging the items onto the screen.

Image 22

Image 23

Image 24

Image 25

Image 26

If you go back to the Graphical Layout tab you will see the string we added string now shows in the GUI layout.

Image 27

Step 4: prepare the first test

Image 28

Image 29

Now enter two more like these to represent Android 4.2.2. Then enter one to represents Android 4.4.2 and an extra large screen.

Image 30

Image 31

Image 32

Image 33

Image 34

Image 35

Step 5: Test on Virtual Android Devices

Image 36

Image 37

Image 38

Image 39Image 40

Image 41

Image 42

API 14 Looks good..

Repeat the above steps for AVD Android 4.2.2

Image 43

Image 44

API 17 Looks good.

Repeat the above steps for AVD Android 4.4.2

Image 45

Image 46

API 19 Looks good...

Step 6: Test on actual Android Devices

Make sure your device has USB Debugging checked in Developer Options, located in Settings. Then plug your android device into your PC or Laptop using its USB cable.

Image 47

Image 48

View HelloWorld in both Portrait and Landscape.

Image 49

Portrait looks good...

Image 50

Landscape looks good...

Run HelloWorld for one hour to see how the application effects the battery level of your device.

Before for instance, record the starting level. Mine is at 100%.

Image 51

Run HelloWorld and leave it running.

Image 52

One hour later, close HelloWorld. Record the level, mine is 97%.

Image 53

Looks good... No significant loss of battery.

The End!

Points of Interest

While creating this tutorial, I actually started with API 8 and was not aware at the time that my theme selection was incompatible. I had to decide whether to keep the error and fix it in the tutorial, or start over. I decided that I would rather use it as an opportunity to teach the user how to look for and fix this type of issue.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)