Android + Eclipse Simple Example Step by Step

By Arvind Rai, August 03, 2014
In this page we will quick start an android application using eclipse. To run the application, eclipse can be integrated with Android Virtual Device that will behave as Android Emulator. Application can be deployed as Android Application Package (apk) file. Application LOG can be seen in console and Android Virtual Device LOG will be available in LogCat. Here we will discuss step by step the creation of simple application of android using eclipse.
We will focus on below points.

1. Perquisites to Run the Application
2. Create Android Simple Application
3. Create Android Virtual Device to Run the Application
4. Check Log in Console and LogCat
5. Install Android Application (APK file) in Android Mobile Phone

Perquisites to Run the Application

Before starting the demo you should be ready with development environment. Find the perquisites to run the application.

1. There should be JDK 6 or above version in your system.
2. Your favorite up-to-date Eclipse Version
3. Go through the link to setup Android in Eclipse before starting the demo.

How to Install Android SDK and ADT Plugin in Eclipse Kepler

Create Android Simple Application

We will create a simple android application starting from wizard. For fast learning you can download the project given on bottom and import it as Android Project from Existing Code and run as Android application. Ensure that you have created Android Virtual Device already.

Go to File->New->Other and search for Android Application Project.
Android + Eclipse Simple Example Step by Step
Click on the Next and fill the information as below.
Android + Eclipse Simple Example Step by Step
Application Name is that name which will appear in the Mobile or Emulator after deployment. Click on the next and next and leave all the default setting as such. Finally click on the finish button. In your eclipse you will able to see your project as below.
Android + Eclipse Simple Example Step by Step
Change by below code.
package com.concretepage.cpandroid;
import android.os.Bundle;
import android.widget.TextView;
public class CpActivity extends Activity {
	public void onCreate(Bundle savedInstanceState) {
        TextView text = new TextView(this);
        text.setText(" This is First Android App. ");
This is activity class which extends class. This is the class which contains methods that will run when our will application run. Define onCreate() method for demo.

Now replace AndroidManifest.xml by below code. This xml keeps all the information related our application.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="7" />
        android:theme="@style/AppTheme" >
            android:label="@string/app_name" >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
Now you are done with your coding part.

Create Android Virtual Device to Run the Application

Eclipse has Android Virtual Device that works like an emulator to run and test the android application. Find the steps to create the Android Virtual Device.

Click on the Window->Android Virtual Device . You will be able to see below scree.
Android + Eclipse Simple Example Step by Step
Initially there will be no row for AVD. You need to create it. Click on create button and fill the data as below.
Android + Eclipse Simple Example Step by Step
To run the application. Start the AVD and then go to your application and right click then go to
Run As->Android Application You will be able to see below screen.
Android + Eclipse Simple Example Step by Step
Your app has been deployed in AVD. You can also check the ICON of your Demo android app in AVD that will look like below.
Android + Eclipse Simple Example Step by Step

Check Log in Console and LogCat

There will be two log. One is eclipse console log that will provide start+ deployment + stop of the application. LogCat is detail log of the Android Virtual Device, which will display all the action being performed in the device in detail. The console log will look like below.
[2014-08-03 19:11:16 - CPAndroid] Android Launch!
[2014-08-03 19:11:16 - CPAndroid] adb is running normally.
[2014-08-03 19:11:16 - CPAndroid] Performing com.concretepage.cpandroid.CpActivity activity launch
[2014-08-03 19:11:16 - CPAndroid] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'AVDOne'
[2014-08-03 19:11:19 - CPAndroid] Application already deployed. No need to reinstall.
[2014-08-03 19:11:19 - CPAndroid] Starting activity com.concretepage.cpandroid.CpActivity on device emulator-5554
[2014-08-03 19:11:22 - CPAndroid] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.concretepage.cpandroid/.CpActivity } 
You can also check LogCat.
08-03 12:38:25.590: E/AndroidRuntime(823): 	at
08-03 12:38:25.590: E/AndroidRuntime(823): 	... 11 more
08-03 12:38:28.860: I/Process(823): Sending signal. PID: 823 SIG: 9
08-03 12:41:10.450: D/gralloc_goldfish(868): Emulator without GPU emulation detected.
08-03 12:47:52.230: I/Choreographer(868): Skipped 107 frames!  The application may be doing too much work on its main thread. 
These two logs play very important role in debugging and developing the android applications.

Install Android Application (APK file) in Android Mobile Phone

You can also install your android application to any android mobile phone. Find the below steps.

1. Find the .apk file. In our demo, go to bin directory and you will get CPAndroid.apk file .
2. Transfer this apk file from your PC to mobile.
3. Click to install and it will be installed as a normal android application.
4. Go to mobile phone menu. You will be able to see the icon of your app. Our demo apk file will create the icon with the name CPAndroid .
5. Click CPAndroid icon to run the demo android app.

To build android project using maven, find the another post. Build Android Project with Maven

Download Source Code


©2024 | Privacy Policy | Contact Us