Monday 18 June 2012

Introduction to Android


Introduction

1. What is Android?
2. What do we need to develop Android applications?
3. Eclipse Update Manager for Android Development Tools (ADT)
4. Configuration
5. Device for Emulation-Android Virtual Device (AVD)

1. What is Android?

Android is operating system based in Linux with Java programming interface, targeted at mobile hardware such as phones and tablet computers. It seems that it keeps increasing market share in smart phone and even trying to get footing into TV world (Google TV with Android OS). It provides tools, Example a compiler, debugger and a device emulator as well as its own Java Virtual Machine (Dalvik). Android is created by the Open Handset Alliance which is lead by Google.
Android uses a special Java Virtual Machine (Dalvik) which is based on the Apache Harmony Java Implementation. Dalvik uses special bytecode there you cannot run standard Java program on Android but   you have to use the Android complier to create this special bytecode.
This is Android Device which contains custom built in Java Codes:


Android supports 2D and 3D graphics using the OpenGL libraries and supports data storage in a SQLite database. For development Google provides the Android Development Tools (ADT) for Eclipse to develop Android applications. Android’s Linux kernel based OS doesn’t come with a sophisticated shell environment, but because the platform is open, we can write and install shells on device.


Android was founded in Palo Alto, California, United States in October 2003. Android was initially developed by four developers by Andy Rubin (co-founder of Danger), Rich Miner (co-founder of Wildfire Communications), Nick Sears (once VP at T-Mobile), Chris White (headed design and interface development at WebTV).
Then Android was acquired by Google on August 17, 2005. Key Employees of Android including Andy Rubin, Rich Miner, Nick Sears and Chris White stayed at the company after the acquisition.
On November 5, 2007 the Open Handset Alliance several companies which include Broadcom Corporation, Google, HTC, Intel, LG, Marvell Technology Group, Motorola, Nvidia, Qualcomm, Samsung Electronics, Spirit Nextel, T-Mobile  Instruments, Sony Ericsson, Vodafone Group.
Android Versions:
The Android beta was released on November 5,2007, while the software developer’s lit (SDK) was released on November 12, 2007.
The Version history of the Android operating system began with the release of the Android beta in November 2007.The first commercial version, Android 1.0, was released in September 2008.Android is a mobile operating system developed by Google and the Open Handset Alliance, and has seen a number of updates to its base operating system since its original release. These updates typically fix buys and new features. Since April 2009, each Android version has been developed under a codename based on a dessert or sweet treat. These versions have been released in alphabetical order Cupcake, Dotnut, Éclair, Froyo (frozen yogurt), Gingerbread, Honeycomb, Ice Cream Sandwich and Jelly Bean. The pre-release versions of Android were dubbed Astro and Bender, but these names could not ultimately be used for trademark reasons. The most recent update to the Android OS was Ice Cream Sandwich v4.04, which released in March 2012.
Android Versions are given below





2. What do we need to develop Android applications?

            ·       JDK (version 6 & 7 required).
We should have a recent version of the Java SDK (JDK) installed on our system.
           ·  Eclipse IDE for Java Developers (versions 3.6-Helios or 3.7-Indigo).
           · Base Android SDK
We now need to download the Android SDK starter package and use it to install our target Android platforms. Download the Android SDK from the Android homepage. The download contains a zip file which you can extract to any place in your file system, e.g. I placed it under “C:\apps\android-sdk-windows”.
The Android SDK archive only contains the tools, and we need to use the SDK Manager to install or update SDK components such as platforms, tools, etc. We must install at least one version of the Android platform using the SDK Manager in order to start developing applications.
          ·       Android Development Tools (ADT)
Installing using Eclipse Update Manager as shown in the next section of this tutorial is much easier.
3. Setting up Android Development Tools (ADT)
Use the update manager of Eclipse to install all available plugins for the Android Development Tools (ADT).
From Eclipse, Help->Install New Software


In the Android Software dialog, click Add. Then, type in “Android Plugin” in the Name field and
URL https://dl-ssl.google.com/android/eclipse in the Location field.




Hit OK, again and select the checkbox next to Developer Tools. Then, the nested tools Android DDMS and Android Development Tools will be selected automatically.


In the Install Details dialog, the Android DDMS and Android Development Tools features are listed.



Click Next.


Click Finish, and restart Eclipse.








4. Configuration

In Eclipse, open the Preferences dialog via Windows->Preferences.
E.g. I placed it under “C:\apps\android-sdk-windows”.
Select Android and type in the installation path of the Android SDK as the picture below.  







After hit Apply, we get:



Hit OK after the target.
Select Window -> Android SDK Manager from the menu.


Install packages if needed.
5. Device for Emulation – Android Virtual Devices (AVD)
For emulation, we need to define a device.
Select Window-> Android AVD Manager from the menu.



Press “New”, then you are about to create a New AVD as the picture below.



Hit “Create AVD” button.
Then you will have




To test if your setup is correct, select your device and press “Start”.
Check the “Scale display to real size” at the Launch Options window below.


At the Launch button, you will have the device, finally.



Android Development Kit Tools

Android SDK Development Tool Commands
Android SDK Development Tools
Windows
Android SDK and AVD Manager
android.bat
Dalvik Debug Monitor
ddms.bat

Importing Project
1. Open the import Dialog
     Select File->Import…to open the import dialog.
2. Import the “My Project” project
In the import dialog, expand the General node and select Existing Projects into Workspace, then click the Browser…button.
In the Browser For Folder dialog, locate the “My Project” folder, select it and click ok. Then, click Finish to import the project. The project now shows up in the Package Explorer.
3. Launch the “My Project” project
Right click the “My Project” in the Package Explorer window, and then select Run as->Android Application from the menu.

Importing Project -@Override issue

When we have the following line of code from the imported package, depending on the compliance level, we may get error message from Eclipse:
@override
public void onClick(DialogInterface dialog, int button)
{
In my case, I got:
Android requires compiler compliance level 5.0 or 6.0. Found ‘1.7’ instead.
Since I’m using Java 1.7.In this case, we need to set the compliance level to 1.6 because 1.5 won’t work with the @override annotation. Right click on the Project->Properties, then set it 1.6 as in the picture below.  



At Apply, we get:



Hit “Yes”, and that’s it.

Deleting Project

Here is the project-wise solution. Right click the “MyProject” in the Package Explorer window, and then select Delete from the menu. In the dialog that appears, ensure that Delete project contents on disk is not selected if we want to use the project’s folders in workspace. If not , we can check it before be click OK.









No comments:

Post a Comment