Installation of Android
Because Android applications run within the Dalvik virtual machine, you can write them on any platform that supports the developer tools. This currently includes the following:
- Microsoft Windows (XP or later)
- Mac OS X 10.4.8 or later (Intel chips only)
To get started, you‘ll need to download and install the following:
The Android SDK
- Java Development Kit (JDK) 5 or 6
- Download the latest JDK from Sun at http://java.sun.com/javase/downloads/index.jsp
Downloading and Installing the SDK
- We can download the latest version of the SDK for your development platform from the Android development homepage at http://developer.android.com/sdk/index.html
- The SDK is presented as a ZIP file containing only the latest version of the Android developer tools. Install it by unzipping the SDK into a new folder.
- Before we can begin development, you need to add at least one SDK Platform; do this on Windows by running the ‗‗SDK Setup.exe‘‘ executable, or on MacOS or Linux by running the ‗‗android‘‘ executable in the tools subfolder.
- In the screen that appears, select the ‗‗Available Packages‘‘ option on the left panel, and then select the SDK Platform versions you wish to install in the ‗‗Sources, Packages, and Archives‘‘ panel on the right.
- The selected platform will then be downloaded to your SDK installation folder and will contain the API libraries, documentation, and several sample applications.
Developing with Eclipse
Using Eclipse with the ADT plug-in for your Android development offers some significant features:
- Eclipse is an open-source IDE (integrated development environment) particularly popular for Java development.
- It‘s available for download for each of the development platforms supported by Android Windows, MacOS and Linux from the Eclipse foundation homepage:
There are many variations available; the following is the recommended configuration for Android:
- Eclipse 3.4 or 3.5 (Galileo)
- Eclipse JDT plug-in
WST and the JDT plug-in are included in most Eclipse IDE packages.
Installing Eclipse consists of uncompressing the download into a new folder. When that‘s done, run the eclipse executable. When it starts for the first time, create a new workspace for your Android development projects.
Installing the ADT Plug-In
Install the developer tools plug-in by following these steps:
- Select Help ➪ Install New Software. . . from within Eclipse.
- In the resulting dialog box, enter the following address into the Work With text entry box and press Enter: https://dl-ssl.google.com/android/eclipse/
- Eclipse will now search for the ADT plug-in. When finished, it will display the available plugin. Select it by clicking the checkbox next to the Developer Tools root node, and click Next.
- Eclipse will now download the plug-in. When it‘s finished, ensure both the Android DDMS and Android Developer Tools plug-ins are selected and click Next.
- Read and then Accept the terms of the license agreement, and click Next and then Finish. As the ADT plug-in is not signed, you‘ll be prompted before the installation continues.
- When installation is complete you‘ll have to restart Eclipse and update the ADT preferences.Restart and select Window ➪ Preferences. . . (or Eclipse ➪ Preferences for MacOS).
- Then select Android from the left panel.
- Click Browse. . . and navigate to the folder into which you unzipped the Android SDK; then click Apply. The list will then update to display each of the available SDK targets. Click OK to complete the SDK installation.
Creating Your First Android Application
You‘ve downloaded the SDK, installed Eclipse, and plugged in the plug-in. You‘re now ready to start programming for Android. Start by creating a new project and setting up your Eclipse run and debug configurations.
Starting a New Android Project
An Android project contains all the files that comprise the source code for your Android app.
To create a new Android project using the Android New Project Wizard, do the following:
- Select File ➪ New ➪ Project.
- Select the Android Project application type from the Android folder and click Next.
- In the dialog that appears, enter the details for your new project. The ‗‗Project name‘‘ is the name of your project file; the ‗‗Package name‘‘ specifies its Java package; Create Activity lets you specify the name of a class that will be your initial Activity; and the ‗‗Application name‘‘ is the friendly name for your application. ‗‗Min SDK Version‘‘ lets you specify the minimum version of the SDK that your application will run on. When you‘ve entered the details, click Finish.
Creating AVDManager (Emulator) :
Before launching the emulator, you must create an Android Virtual Device (AVD) which defines the system image and device settings used by the emulator. Some of the settings are,
- configure the version of the Android system
- size of the SD card
- set of hardware options
- emulator skin
- screen resolution, etc.
An Android Virtual Device (AVD) definition lets you define the characteristics of an Android phone, tablet, Android Wear, or Android TV device that you want to simulate in the Android Emulator. The AVD Manager helps you easily create and manage AVDs.
|………>Name(enter some name Ex:saitech)
|…………….>Target(select version with API level Ex :2.2,8)
|……………> create AVD.
Run our application on created Emulator(Ex : On saitech) :
|……………….>Right Click(Run As)
Creating a Launch Configuration
Launch configurations let you specify runtime options for running and debugging applications. Using a launch configuration, you can specify the following:
- The Project and Activity to launch
- The virtual device and emulator options to use
- Input/output settings (including console defaults)
We can specify different launch configurations for running and debugging applications. The following steps show how to create a launch configuration for an Android application:
- Select Run Configurations. . . or Debug Configurations. . . from the Run menu.
- Right-click Android Application on the project type list, and select New.
- Enter a name for the configuration. You can create multiple configurations for each project, so create a descriptive title that will help you identify this particular setup.
- Now choose your start-up options. The first (Android) tab lets you select the project to run and the Activity that you want to start when you run (or debug) the application.
- Use the Target tab, to select the default virtual device to launch on, or select manual to select a device or AVD each time.
6. Finally, set any additional properties in the Common tab.
7. Click Apply, and your launch configuration will be saved.
Running and Debugging Your Android Applications
You‘ve created your first project and created the run and debug configurations for it. Before making any changes, test your installation and configurations by running and debugging the Hello World project. From the Run menu, select Run or Debug to launch the most recently selected configuration, or select Run Configurations or Debug Configurations to select a specific configuration to use.