Click here to Skip to main content
15,886,075 members
Articles / Mobile Apps / Android

Creating a Simple Hello World Android Project

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
3 Aug 2014CPOL4 min read 70.6K   15   6
Create a simple Hello world android project with Android Studio run in emulator and depoly on Mobile Device

Introduction

Create a simple Hello world android project with Android Studio run in emulator and depoly on Mobile Device

it can be created by using Android Studio 0.8.0.

 

Creating a Simple Hello World Android Project

            To create a simple Hello World Android project can be done either with Eclipse or Android Studio. Here I am going to explain how it can be created by using Android Studio 0.8.0.

Android Studio:

Studio can be downloaded from the below link.

http://tools.android.com/download/studio/beta

Pre-requisite:

            Ensure appropriate JDK version is installed.

            Download appropriate Android SDK based on the version we are developing.

SDK

Create new project

 First step load Android Studio. Click on the New project…

New Project

Configure the New Project

Enter the application and company domain and select the project location as shown below and click on Next button.

Configure your new project

Select form factor

Select the appropriate minimum version of android we are going to target as shown in the list as below

New Project

Select the Activity

Select the template need as pre requirement. I have selected the blank activity.

Add an activity to Mobile

 The class will be created based on the Activity Name entered.

New File

Click on the finish button. The project gets created and will be shown as below

Finish

Files / Components

Important files and directory of Android project to be known and their purpose

  1. src - This contains the .java source files for your project. By default, it includes an MainActivity.java source file having an activity class that runs when your app is launched using the app icon.
  2. generated - This contains the .R file, a compiler-generated file that references all the resources found in your project. You should not modify this file
  3. bin - This folder contains the Android package files .apk built by the ADT during the build process and everything else needed to run an Android application.
  4. res/drawable-hdpi - This is a directory for drawable objects that are designed for high-density screens.
  5. res/layout - This is a directory for files that define your app's user interface.
  6. res/values - This is a directory for other various XML files that contain a collection of resources, such as strings and colors definitions.
  7. AndroidManifest.xml - This is the manifest file which describes the fundamental characteristics of the app and defines each of its components.

 

File Components

 

String file

The strings.xml file is located in the res/values folder and it contains all the text that your application uses. For example, the names of buttons, labels, default text, and similar types of strings go into this file. This file is responsible for their textual content. For example, a default strings file will look like as following file

 

R file

The gen/myapps.helloworld/R.java file is the glue between the activity Java files like Main.java and the resources like strings.xml. It is an automatically generated file and you should not modify the content of the R.java file. Following is a sample of R.java fileR File

Layout File

The activity_main.xml is a layout file available in res/layout directory, that is referenced by your application when building its interface. You will modify this file very frequently to change the layout of your application. For your "Hello World!" application, this file will have following content related to default layout

     Text Mode

Layout Text

Layout Design

Layout Design

Running app on Emulator

Emulator takes more time to load so before running app we should start emulator. Emulator can be started from SDK manager tools Manage AVDs.

SDK ManagerAVD Manager

Create the AVD and click on the start to run the emulator

AVD Manager

Once emulator is started it will get loaded by creating an AVD Manager

Emulator

Things to do on Mobile Device

Pre-requisite

            Generate a signed APK from the Android Studio under Build / generate signed APK.

Steps

  1. Go to settings on Mobile Device
  2. Tap on applications or Developer options
  3.  If it is applications options on mobile device follow below steps
    1. Put a check for Unknown Sources (to allow installation of non-Market applications)
    2. Tap on Development (to set options for application development)
  4. Check on USB debugging
  5. Plug the USB cable to computer.
  6. Go the platform-tools under studio directory  and run the following comment     
    1. adb install app-release.apk. App installs
    2. On success full install you can run the app on mobile.

 

 

License

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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionTime to launch emulator Pin
Pawan Gupta Lucknow18-Feb-15 11:26
Pawan Gupta Lucknow18-Feb-15 11:26 
GeneralThanks for entering! Pin
Kevin Priddle5-Aug-14 7:10
professionalKevin Priddle5-Aug-14 7:10 
QuestionImages Pin
PeterWalter4-Aug-14 22:35
professionalPeterWalter4-Aug-14 22:35 
AnswerRe: Images Pin
Sivamurugan Perumal5-Aug-14 3:38
Sivamurugan Perumal5-Aug-14 3:38 
GeneralRe: Images Pin
PeterWalter5-Aug-14 4:09
professionalPeterWalter5-Aug-14 4:09 
GeneralRe: Images Pin
Sivamurugan Perumal5-Aug-14 5:26
Sivamurugan Perumal5-Aug-14 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.